Compare commits

...

1 Commits

Author SHA1 Message Date
speakeasybot
c1bc2419c8 ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.158.0 2024-01-31 15:06:07 +00:00
28 changed files with 1151 additions and 63 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: 95d4ac4070b7f9db42126fc81b258e02 docChecksum: 94439465ae5d544f0e52b00719af05ee
docVersion: 0.0.3 docVersion: 0.0.3
speakeasyVersion: internal speakeasyVersion: internal
generationVersion: 2.237.3 generationVersion: 2.239.4
releaseVersion: 0.1.3 releaseVersion: 0.2.0
configChecksum: 2e7d024f42a6fdcfee4d2cc46bb9827e configChecksum: cab54fc8ee2784bf822df0198252c4f5
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
@@ -18,6 +18,7 @@ features:
flattening: 2.81.1 flattening: 2.81.1
globalSecurity: 2.82.4 globalSecurity: 2.82.4
globalServerURLs: 2.82.1 globalServerURLs: 2.82.1
methodServerURLs: 2.82.1
nameOverrides: 2.81.1 nameOverrides: 2.81.1
unions: 2.85.2 unions: 2.85.2
generatedFiles: generatedFiles:
@@ -29,6 +30,8 @@ generatedFiles:
- search.go - search.go
- library.go - library.go
- log.go - log.go
- tv.go
- plex.go
- playlists.go - playlists.go
- security.go - security.go
- sessions.go - sessions.go
@@ -90,6 +93,8 @@ generatedFiles:
- /models/operations/logline.go - /models/operations/logline.go
- /models/operations/logmultiline.go - /models/operations/logmultiline.go
- /models/operations/enablepapertrail.go - /models/operations/enablepapertrail.go
- /models/operations/getpin.go
- /models/operations/gettoken.go
- /models/operations/createplaylist.go - /models/operations/createplaylist.go
- /models/operations/getplaylists.go - /models/operations/getplaylists.go
- /models/operations/getplaylist.go - /models/operations/getplaylist.go
@@ -145,6 +150,8 @@ generatedFiles:
- /models/sdkerrors/logline.go - /models/sdkerrors/logline.go
- /models/sdkerrors/logmultiline.go - /models/sdkerrors/logmultiline.go
- /models/sdkerrors/enablepapertrail.go - /models/sdkerrors/enablepapertrail.go
- /models/sdkerrors/getpin.go
- /models/sdkerrors/gettoken.go
- /models/sdkerrors/createplaylist.go - /models/sdkerrors/createplaylist.go
- /models/sdkerrors/getplaylists.go - /models/sdkerrors/getplaylists.go
- /models/sdkerrors/getplaylist.go - /models/sdkerrors/getplaylist.go
@@ -275,7 +282,7 @@ generatedFiles:
- docs/models/operations/getrecentlyaddedmediacontainer.md - docs/models/operations/getrecentlyaddedmediacontainer.md
- docs/models/operations/getrecentlyaddedresponsebody.md - docs/models/operations/getrecentlyaddedresponsebody.md
- docs/models/operations/getrecentlyaddedresponse.md - docs/models/operations/getrecentlyaddedresponse.md
- docs/models/operations/location.md - docs/models/operations/getlibrarieslocation.md
- docs/models/operations/getlibrariesdirectory.md - docs/models/operations/getlibrariesdirectory.md
- docs/models/operations/getlibrariesmediacontainer.md - docs/models/operations/getlibrariesmediacontainer.md
- docs/models/operations/getlibrariesresponsebody.md - docs/models/operations/getlibrariesresponsebody.md
@@ -350,6 +357,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/getpinrequest.md
- docs/models/operations/location.md
- docs/models/operations/getpinresponsebody.md
- docs/models/operations/getpinresponse.md
- docs/models/operations/gettokenrequest.md
- docs/models/operations/gettokenresponse.md
- docs/models/operations/queryparamtype.md - docs/models/operations/queryparamtype.md
- docs/models/operations/smart.md - docs/models/operations/smart.md
- docs/models/operations/createplaylistrequest.md - docs/models/operations/createplaylistrequest.md
@@ -507,6 +520,10 @@ generatedFiles:
- docs/models/sdkerrors/logmultilineresponsebody.md - docs/models/sdkerrors/logmultilineresponsebody.md
- docs/models/sdkerrors/enablepapertrailerrors.md - docs/models/sdkerrors/enablepapertrailerrors.md
- docs/models/sdkerrors/enablepapertrailresponsebody.md - docs/models/sdkerrors/enablepapertrailresponsebody.md
- docs/models/sdkerrors/getpinerrors.md
- docs/models/sdkerrors/getpinresponsebody.md
- docs/models/sdkerrors/gettokenerrors.md
- docs/models/sdkerrors/gettokenresponsebody.md
- docs/models/sdkerrors/createplaylisterrors.md - docs/models/sdkerrors/createplaylisterrors.md
- docs/models/sdkerrors/createplaylistresponsebody.md - docs/models/sdkerrors/createplaylistresponsebody.md
- docs/models/sdkerrors/getplaylistserrors.md - docs/models/sdkerrors/getplaylistserrors.md
@@ -557,10 +574,14 @@ generatedFiles:
- docs/sdks/search/README.md - docs/sdks/search/README.md
- docs/sdks/library/README.md - docs/sdks/library/README.md
- docs/sdks/log/README.md - docs/sdks/log/README.md
- docs/sdks/plex/README.md
- docs/models/operations/option.md
- docs/sdks/tv/README.md
- docs/sdks/playlists/README.md - docs/sdks/playlists/README.md
- docs/sdks/security/README.md - docs/sdks/security/README.md
- docs/sdks/sessions/README.md - docs/sdks/sessions/README.md
- docs/sdks/updater/README.md - docs/sdks/updater/README.md
- docs/sdks/video/README.md - docs/sdks/video/README.md
- USAGE.md - USAGE.md
- models/operations/options.go
- .gitattributes - .gitattributes

View File

@@ -113,6 +113,12 @@ func main() {
* [LogMultiLine](docs/sdks/log/README.md#logmultiline) - Logging a multi-line message * [LogMultiLine](docs/sdks/log/README.md#logmultiline) - Logging a multi-line message
* [EnablePaperTrail](docs/sdks/log/README.md#enablepapertrail) - Enabling Papertrail * [EnablePaperTrail](docs/sdks/log/README.md#enablepapertrail) - Enabling Papertrail
### [Plex.Tv](docs/sdks/tv/README.md)
* [GetPin](docs/sdks/tv/README.md#getpin) - Get a Pin
* [GetToken](docs/sdks/tv/README.md#gettoken) - Get Access Token
### [Playlists](docs/sdks/playlists/README.md) ### [Playlists](docs/sdks/playlists/README.md)
* [CreatePlaylist](docs/sdks/playlists/README.md#createplaylist) - Create a Playlist * [CreatePlaylist](docs/sdks/playlists/README.md#createplaylist) - Create a Playlist
@@ -278,6 +284,41 @@ func main() {
} }
} }
```
### Override Server URL Per-Operation
The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:
```go
package main
import (
"context"
"github.com/LukeHagar/plexgo"
"github.com/LukeHagar/plexgo/models/components"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var xPlexClientIdentifier string = "string"
var strong *bool = false
ctx := context.Background()
res, err := s.Plex.Tv.GetPin(ctx, operations.WithServerURL("https://plex.tv/api/v2"), xPlexClientIdentifier, strong)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
``` ```
<!-- End Server Selection [server] --> <!-- End Server Selection [server] -->

View File

@@ -89,3 +89,13 @@ Based on:
- [go v0.1.3] . - [go v0.1.3] .
### Releases ### Releases
- [Go v0.1.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.1.3 - . - [Go v0.1.3] https://github.com/LukeHagar/plexgo/releases/tag/v0.1.3 - .
## 2024-01-31 15:05:54
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.158.0 (2.239.4) https://github.com/speakeasy-api/speakeasy
### Generated
- [go v0.2.0] .
### Releases
- [Go v0.2.0] https://github.com/LukeHagar/plexgo/releases/tag/v0.2.0 - .

View File

@@ -4,7 +4,7 @@
## Fields ## Fields
| Field | Type | Required | Description | Example | | Field | Type | Required | Description | Example |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| `AllowSync` | **bool* | :heavy_minus_sign: | N/A | true | | `AllowSync` | **bool* | :heavy_minus_sign: | N/A | true |
| `Art` | **string* | :heavy_minus_sign: | N/A | /:/resources/movie-fanart.jpg | | `Art` | **string* | :heavy_minus_sign: | N/A | /:/resources/movie-fanart.jpg |
| `Composite` | **string* | :heavy_minus_sign: | N/A | /library/sections/1/composite/1705615584 | | `Composite` | **string* | :heavy_minus_sign: | N/A | /library/sections/1/composite/1705615584 |
@@ -25,4 +25,4 @@
| `Directory` | **bool* | :heavy_minus_sign: | N/A | true | | `Directory` | **bool* | :heavy_minus_sign: | N/A | true |
| `ContentChangedAt` | **int* | :heavy_minus_sign: | N/A | 3192854 | | `ContentChangedAt` | **int* | :heavy_minus_sign: | N/A | 3192854 |
| `Hidden` | **int* | :heavy_minus_sign: | N/A | 0 | | `Hidden` | **int* | :heavy_minus_sign: | N/A | 0 |
| `Location` | [][operations.Location](../../models/operations/location.md) | :heavy_minus_sign: | N/A | [{"id":1,"path":"/movies"}] | | `Location` | [][operations.GetLibrariesLocation](../../models/operations/getlibrarieslocation.md) | :heavy_minus_sign: | N/A | [{"id":1,"path":"/movies"}] |

View File

@@ -0,0 +1,9 @@
# GetLibrariesLocation
## Fields
| Field | Type | Required | Description | Example |
| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ |
| `ID` | **int* | :heavy_minus_sign: | N/A | 1 |
| `Path` | **string* | :heavy_minus_sign: | N/A | /movies |

View File

@@ -0,0 +1,9 @@
# GetPinRequest
## Fields
| Field | Type | Required | Description |
| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | Plex Authentication Token |
| `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/> |

View File

@@ -0,0 +1,11 @@
# GetPinResponse
## Fields
| Field | Type | Required | Description |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation |
| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation |
| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing |
| `Object` | [*operations.GetPinResponseBody](../../models/operations/getpinresponsebody.md) | :heavy_minus_sign: | The Pin |

View File

@@ -0,0 +1,21 @@
# GetPinResponseBody
The Pin
## Fields
| Field | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ID` | **float64* | :heavy_minus_sign: | PinID for use with authentication | 1272322473 |
| `Code` | **string* | :heavy_minus_sign: | N/A | 3patfx1a78ukcbr7x0n9bl26t |
| `Product` | **string* | :heavy_minus_sign: | N/A | Plex Web |
| `Trusted` | **bool* | :heavy_minus_sign: | N/A | |
| `Qr` | **string* | :heavy_minus_sign: | a link to a QR code hosted on plex.tv <br/>The QR code redirects to the relevant `plex.tv/link` authentication page<br/>Which then prompts the user for the 4 Digit Link Pin<br/> | https://plex.tv/api/v2/pins/qr/3patfx1a78ukcbr7x0n9bl26t |
| `ClientIdentifier` | **string* | :heavy_minus_sign: | N/A | Postman |
| `Location` | [*operations.Location](../../models/operations/location.md) | :heavy_minus_sign: | N/A | |
| `ExpiresIn` | **float64* | :heavy_minus_sign: | N/A | 1800 |
| `CreatedAt` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | 2023-04-12 17:00:03 +0000 UTC |
| `ExpiresAt` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | 2023-04-12 17:30:03 +0000 UTC |
| `AuthToken` | **string* | :heavy_minus_sign: | N/A | |
| `NewRegistration` | **string* | :heavy_minus_sign: | N/A | |

View File

@@ -0,0 +1,9 @@
# GetTokenRequest
## Fields
| Field | Type | Required | Description |
| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- |
| `PinID` | *string* | :heavy_check_mark: | The PinID to retrieve an access token for |
| `XPlexClientIdentifier` | *string* | :heavy_check_mark: | Plex Authentication Token |

View File

@@ -0,0 +1,10 @@
# GetTokenResponse
## Fields
| Field | Type | Required | Description |
| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- |
| `ContentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation |
| `StatusCode` | *int* | :heavy_check_mark: | HTTP response status code for this operation |
| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing |

View File

@@ -4,6 +4,14 @@
## Fields ## Fields
| Field | Type | Required | Description | Example | | Field | Type | Required | Description | Example |
| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | | ---------------------------- | ---------------------------- | ---------------------------- | ---------------------------- | ---------------------------- |
| `ID` | **int* | :heavy_minus_sign: | N/A | 1 | | `Code` | **string* | :heavy_minus_sign: | N/A | US |
| `Path` | **string* | :heavy_minus_sign: | N/A | /movies | | `EuropeanUnionMember` | **bool* | :heavy_minus_sign: | N/A | |
| `ContinentCode` | **string* | :heavy_minus_sign: | N/A | NA |
| `Country` | **string* | :heavy_minus_sign: | N/A | United States |
| `City` | **string* | :heavy_minus_sign: | N/A | Austin |
| `TimeZone` | **string* | :heavy_minus_sign: | N/A | America/Chicago |
| `PostalCode` | **float64* | :heavy_minus_sign: | N/A | 78732 |
| `InPrivacyRestrictedCountry` | **bool* | :heavy_minus_sign: | N/A | |
| `Subdivisions` | **string* | :heavy_minus_sign: | N/A | Texas |
| `Coordinates` | **string* | :heavy_minus_sign: | N/A | 30.3768 -97.8935 |

View File

@@ -0,0 +1,37 @@
## Options
### WithServerURL
WithServerURL allows providing an alternative server URL.
```go
operations.WithServerURL("http://api.example.com")
```
## WithTemplatedServerURL
WithTemplatedServerURL allows providing an alternative server URL with templated parameters.
```go
operations.WithTemplatedServerURL("http://{host}:{port}", map[string]string{
"host": "api.example.com",
"port": "8080",
})
```
### WithRetries
WithRetries allows customizing the default retry configuration. Only usable with methods that mention they support retries.
```go
operations.WithRetries(utils.RetryConfig{
Strategy: "backoff",
Backoff: utils.BackoffStrategy{
InitialInterval: 500 * time.Millisecond,
MaxInterval: 60 * time.Second,
Exponent: 1.5,
MaxElapsedTime: 5 * time.Minute,
},
RetryConnectionErrors: true,
})
```

View File

@@ -0,0 +1,10 @@
# GetPinErrors
## Fields
| Field | Type | Required | Description | Example |
| ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- |
| `Code` | **float64* | :heavy_minus_sign: | N/A | 1000 |
| `Message` | **string* | :heavy_minus_sign: | N/A | X-Plex-Client-Identifier is missing |
| `Status` | **float64* | :heavy_minus_sign: | N/A | 400 |

View File

@@ -0,0 +1,11 @@
# GetPinResponseBody
X-Plex-Client-Identifier is missing
## Fields
| Field | Type | Required | Description |
| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
| `Errors` | [][sdkerrors.GetPinErrors](../../models/sdkerrors/getpinerrors.md) | :heavy_minus_sign: | N/A |
| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing |

View File

@@ -0,0 +1,10 @@
# GetTokenErrors
## Fields
| Field | Type | Required | Description | Example |
| ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- |
| `Code` | **float64* | :heavy_minus_sign: | N/A | 1000 |
| `Message` | **string* | :heavy_minus_sign: | N/A | X-Plex-Client-Identifier is missing |
| `Status` | **float64* | :heavy_minus_sign: | N/A | 400 |

View File

@@ -0,0 +1,11 @@
# GetTokenResponseBody
X-Plex-Client-Identifier is missing
## Fields
| Field | Type | Required | Description |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| `Errors` | [][sdkerrors.GetTokenErrors](../../models/sdkerrors/gettokenerrors.md) | :heavy_minus_sign: | N/A |
| `RawResponse` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing |

5
docs/sdks/plex/README.md Normal file
View File

@@ -0,0 +1,5 @@
# Plex
(*Plex*)
### Available Operations

120
docs/sdks/tv/README.md Normal file
View File

@@ -0,0 +1,120 @@
# Tv
(*Plex.Tv*)
### Available Operations
* [GetPin](#getpin) - Get a Pin
* [GetToken](#gettoken) - Get Access Token
## GetPin
Retrieve a Pin from Plex.tv for authentication flows
### Example Usage
```go
package main
import(
"github.com/LukeHagar/plexgo/models/components"
"github.com/LukeHagar/plexgo"
"context"
"log"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var xPlexClientIdentifier string = "string"
var strong *bool = false
ctx := context.Background()
res, err := s.Plex.Tv.GetPin(ctx, xPlexClientIdentifier, strong)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
```
### Parameters
| 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: | Plex Authentication Token |
| `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/> |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
### Response
**[*operations.GetPinResponse](../../models/operations/getpinresponse.md), error**
| Error Object | Status Code | Content Type |
| ---------------------------- | ---------------------------- | ---------------------------- |
| sdkerrors.GetPinResponseBody | 400 | application/json |
| sdkerrors.SDKError | 4xx-5xx | */* |
## GetToken
Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
### Example Usage
```go
package main
import(
"github.com/LukeHagar/plexgo/models/components"
"github.com/LukeHagar/plexgo"
"context"
"log"
"net/http"
)
func main() {
s := plexgo.New(
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var pinID string = "string"
var xPlexClientIdentifier string = "string"
ctx := context.Background()
res, err := s.Plex.Tv.GetToken(ctx, pinID, xPlexClientIdentifier)
if err != nil {
log.Fatal(err)
}
if res.StatusCode == http.StatusOK {
// handle response
}
}
```
### Parameters
| Parameter | Type | Required | Description |
| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- |
| `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: | Plex Authentication Token |
| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. |
### Response
**[*operations.GetTokenResponse](../../models/operations/gettokenresponse.md), error**
| Error Object | Status Code | Content Type |
| ------------------------------ | ------------------------------ | ------------------------------ |
| sdkerrors.GetTokenResponseBody | 400 | application/json |
| sdkerrors.SDKError | 4xx-5xx | */* |

View File

@@ -8,7 +8,7 @@ generation:
fixes: fixes:
nameResolutionDec2023: false nameResolutionDec2023: false
go: go:
version: 0.1.3 version: 0.2.0
clientServerStatusCodesAsErrors: true clientServerStatusCodesAsErrors: true
flattenGlobalSecurity: true flattenGlobalSecurity: true
imports: imports:

View File

@@ -6,19 +6,19 @@ import (
"net/http" "net/http"
) )
type Location struct { type GetLibrariesLocation struct {
ID *int `json:"id,omitempty"` ID *int `json:"id,omitempty"`
Path *string `json:"path,omitempty"` Path *string `json:"path,omitempty"`
} }
func (o *Location) GetID() *int { func (o *GetLibrariesLocation) GetID() *int {
if o == nil { if o == nil {
return nil return nil
} }
return o.ID return o.ID
} }
func (o *Location) GetPath() *string { func (o *GetLibrariesLocation) GetPath() *string {
if o == nil { if o == nil {
return nil return nil
} }
@@ -46,7 +46,7 @@ type GetLibrariesDirectory struct {
Directory *bool `json:"directory,omitempty"` Directory *bool `json:"directory,omitempty"`
ContentChangedAt *int `json:"contentChangedAt,omitempty"` ContentChangedAt *int `json:"contentChangedAt,omitempty"`
Hidden *int `json:"hidden,omitempty"` Hidden *int `json:"hidden,omitempty"`
Location []Location `json:"Location,omitempty"` Location []GetLibrariesLocation `json:"Location,omitempty"`
} }
func (o *GetLibrariesDirectory) GetAllowSync() *bool { func (o *GetLibrariesDirectory) GetAllowSync() *bool {
@@ -189,7 +189,7 @@ func (o *GetLibrariesDirectory) GetHidden() *int {
return o.Hidden return o.Hidden
} }
func (o *GetLibrariesDirectory) GetLocation() []Location { func (o *GetLibrariesDirectory) GetLocation() []GetLibrariesLocation {
if o == nil { if o == nil {
return nil return nil
} }

286
models/operations/getpin.go Normal file
View File

@@ -0,0 +1,286 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package operations
import (
"github.com/LukeHagar/plexgo/internal/utils"
"net/http"
"time"
)
var GetPinServerList = []string{
"https://plex.tv/api/v2",
}
type GetPinRequest struct {
// Plex Authentication Token
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"`
}
func (g GetPinRequest) MarshalJSON() ([]byte, error) {
return utils.MarshalJSON(g, "", false)
}
func (g *GetPinRequest) UnmarshalJSON(data []byte) error {
if err := utils.UnmarshalJSON(data, &g, "", false, false); err != nil {
return err
}
return nil
}
func (o *GetPinRequest) GetXPlexClientIdentifier() string {
if o == nil {
return ""
}
return o.XPlexClientIdentifier
}
func (o *GetPinRequest) GetStrong() *bool {
if o == nil {
return nil
}
return o.Strong
}
type Location struct {
Code *string `json:"code,omitempty"`
EuropeanUnionMember *bool `json:"european_union_member,omitempty"`
ContinentCode *string `json:"continent_code,omitempty"`
Country *string `json:"country,omitempty"`
City *string `json:"city,omitempty"`
TimeZone *string `json:"time_zone,omitempty"`
PostalCode *float64 `json:"postal_code,omitempty"`
InPrivacyRestrictedCountry *bool `json:"in_privacy_restricted_country,omitempty"`
Subdivisions *string `json:"subdivisions,omitempty"`
Coordinates *string `json:"coordinates,omitempty"`
}
func (o *Location) GetCode() *string {
if o == nil {
return nil
}
return o.Code
}
func (o *Location) GetEuropeanUnionMember() *bool {
if o == nil {
return nil
}
return o.EuropeanUnionMember
}
func (o *Location) GetContinentCode() *string {
if o == nil {
return nil
}
return o.ContinentCode
}
func (o *Location) GetCountry() *string {
if o == nil {
return nil
}
return o.Country
}
func (o *Location) GetCity() *string {
if o == nil {
return nil
}
return o.City
}
func (o *Location) GetTimeZone() *string {
if o == nil {
return nil
}
return o.TimeZone
}
func (o *Location) GetPostalCode() *float64 {
if o == nil {
return nil
}
return o.PostalCode
}
func (o *Location) GetInPrivacyRestrictedCountry() *bool {
if o == nil {
return nil
}
return o.InPrivacyRestrictedCountry
}
func (o *Location) GetSubdivisions() *string {
if o == nil {
return nil
}
return o.Subdivisions
}
func (o *Location) GetCoordinates() *string {
if o == nil {
return nil
}
return o.Coordinates
}
// GetPinResponseBody - The Pin
type GetPinResponseBody struct {
// PinID for use with authentication
ID *float64 `json:"id,omitempty"`
Code *string `json:"code,omitempty"`
Product *string `json:"product,omitempty"`
Trusted *bool `json:"trusted,omitempty"`
// a link to a QR code hosted on plex.tv
// The QR code redirects to the relevant `plex.tv/link` authentication page
// Which then prompts the user for the 4 Digit Link Pin
//
Qr *string `json:"qr,omitempty"`
ClientIdentifier *string `json:"clientIdentifier,omitempty"`
Location *Location `json:"location,omitempty"`
ExpiresIn *float64 `json:"expiresIn,omitempty"`
CreatedAt *time.Time `json:"createdAt,omitempty"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
AuthToken *string `json:"authToken,omitempty"`
NewRegistration *string `json:"newRegistration,omitempty"`
}
func (g GetPinResponseBody) MarshalJSON() ([]byte, error) {
return utils.MarshalJSON(g, "", false)
}
func (g *GetPinResponseBody) UnmarshalJSON(data []byte) error {
if err := utils.UnmarshalJSON(data, &g, "", false, false); err != nil {
return err
}
return nil
}
func (o *GetPinResponseBody) GetID() *float64 {
if o == nil {
return nil
}
return o.ID
}
func (o *GetPinResponseBody) GetCode() *string {
if o == nil {
return nil
}
return o.Code
}
func (o *GetPinResponseBody) GetProduct() *string {
if o == nil {
return nil
}
return o.Product
}
func (o *GetPinResponseBody) GetTrusted() *bool {
if o == nil {
return nil
}
return o.Trusted
}
func (o *GetPinResponseBody) GetQr() *string {
if o == nil {
return nil
}
return o.Qr
}
func (o *GetPinResponseBody) GetClientIdentifier() *string {
if o == nil {
return nil
}
return o.ClientIdentifier
}
func (o *GetPinResponseBody) GetLocation() *Location {
if o == nil {
return nil
}
return o.Location
}
func (o *GetPinResponseBody) GetExpiresIn() *float64 {
if o == nil {
return nil
}
return o.ExpiresIn
}
func (o *GetPinResponseBody) GetCreatedAt() *time.Time {
if o == nil {
return nil
}
return o.CreatedAt
}
func (o *GetPinResponseBody) GetExpiresAt() *time.Time {
if o == nil {
return nil
}
return o.ExpiresAt
}
func (o *GetPinResponseBody) GetAuthToken() *string {
if o == nil {
return nil
}
return o.AuthToken
}
func (o *GetPinResponseBody) GetNewRegistration() *string {
if o == nil {
return nil
}
return o.NewRegistration
}
type GetPinResponse struct {
// HTTP response content type for this operation
ContentType string
// HTTP response status code for this operation
StatusCode int
// Raw HTTP response; suitable for custom response parsing
RawResponse *http.Response
// The Pin
Object *GetPinResponseBody
}
func (o *GetPinResponse) GetContentType() string {
if o == nil {
return ""
}
return o.ContentType
}
func (o *GetPinResponse) GetStatusCode() int {
if o == nil {
return 0
}
return o.StatusCode
}
func (o *GetPinResponse) GetRawResponse() *http.Response {
if o == nil {
return nil
}
return o.RawResponse
}
func (o *GetPinResponse) GetObject() *GetPinResponseBody {
if o == nil {
return nil
}
return o.Object
}

View File

@@ -0,0 +1,62 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package operations
import (
"net/http"
)
var GetTokenServerList = []string{
"https://plex.tv/api/v2",
}
type GetTokenRequest struct {
// The PinID to retrieve an access token for
PinID string `pathParam:"style=simple,explode=false,name=pinID"`
// Plex Authentication Token
XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"`
}
func (o *GetTokenRequest) GetPinID() string {
if o == nil {
return ""
}
return o.PinID
}
func (o *GetTokenRequest) GetXPlexClientIdentifier() string {
if o == nil {
return ""
}
return o.XPlexClientIdentifier
}
type GetTokenResponse struct {
// HTTP response content type for this operation
ContentType string
// HTTP response status code for this operation
StatusCode int
// Raw HTTP response; suitable for custom response parsing
RawResponse *http.Response
}
func (o *GetTokenResponse) GetContentType() string {
if o == nil {
return ""
}
return o.ContentType
}
func (o *GetTokenResponse) GetStatusCode() int {
if o == nil {
return 0
}
return o.StatusCode
}
func (o *GetTokenResponse) GetRawResponse() *http.Response {
if o == nil {
return nil
}
return o.RawResponse
}

View File

@@ -0,0 +1,63 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package operations
import (
"errors"
"github.com/LukeHagar/plexgo/internal/utils"
)
var ErrUnsupportedOption = errors.New("unsupported option")
const (
SupportedOptionServerURL = "serverURL"
SupportedOptionRetries = "retries"
SupportedOptionAcceptHeaderOverride = "acceptHeaderOverride"
)
type Options struct {
ServerURL *string
Retries *utils.RetryConfig
}
type Option func(*Options, ...string) error
// WithServerURL allows providing an alternative server URL.
func WithServerURL(serverURL string) Option {
return func(opts *Options, supportedOptions ...string) error {
if !utils.Contains(supportedOptions, SupportedOptionServerURL) {
return ErrUnsupportedOption
}
opts.ServerURL = &serverURL
return nil
}
}
// WithTemplatedServerURL allows providing an alternative server URL with templated parameters.
func WithTemplatedServerURL(serverURL string, params map[string]string) Option {
return func(opts *Options, supportedOptions ...string) error {
if !utils.Contains(supportedOptions, SupportedOptionServerURL) {
return ErrUnsupportedOption
}
if params != nil {
serverURL = utils.ReplaceParameters(serverURL, params)
}
opts.ServerURL = &serverURL
return nil
}
}
// WithRetries allows customizing the default retry configuration.
func WithRetries(config utils.RetryConfig) Option {
return func(opts *Options, supportedOptions ...string) error {
if !utils.Contains(supportedOptions, SupportedOptionRetries) {
return ErrUnsupportedOption
}
opts.Retries = &config
return nil
}
}

View File

@@ -0,0 +1,49 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package sdkerrors
import (
"encoding/json"
"net/http"
)
type GetPinErrors struct {
Code *float64 `json:"code,omitempty"`
Message *string `json:"message,omitempty"`
Status *float64 `json:"status,omitempty"`
}
func (o *GetPinErrors) GetCode() *float64 {
if o == nil {
return nil
}
return o.Code
}
func (o *GetPinErrors) GetMessage() *string {
if o == nil {
return nil
}
return o.Message
}
func (o *GetPinErrors) GetStatus() *float64 {
if o == nil {
return nil
}
return o.Status
}
// GetPinResponseBody - X-Plex-Client-Identifier is missing
type GetPinResponseBody struct {
Errors []GetPinErrors `json:"errors,omitempty"`
// Raw HTTP response; suitable for custom response parsing
RawResponse *http.Response `json:"-"`
}
var _ error = &GetPinResponseBody{}
func (e *GetPinResponseBody) Error() string {
data, _ := json.Marshal(e)
return string(data)
}

View File

@@ -0,0 +1,49 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package sdkerrors
import (
"encoding/json"
"net/http"
)
type GetTokenErrors struct {
Code *float64 `json:"code,omitempty"`
Message *string `json:"message,omitempty"`
Status *float64 `json:"status,omitempty"`
}
func (o *GetTokenErrors) GetCode() *float64 {
if o == nil {
return nil
}
return o.Code
}
func (o *GetTokenErrors) GetMessage() *string {
if o == nil {
return nil
}
return o.Message
}
func (o *GetTokenErrors) GetStatus() *float64 {
if o == nil {
return nil
}
return o.Status
}
// GetTokenResponseBody - X-Plex-Client-Identifier is missing
type GetTokenResponseBody struct {
Errors []GetTokenErrors `json:"errors,omitempty"`
// Raw HTTP response; suitable for custom response parsing
RawResponse *http.Response `json:"-"`
}
var _ error = &GetTokenResponseBody{}
func (e *GetTokenResponseBody) Error() string {
data, _ := json.Marshal(e)
return string(data)
}

16
plex.go Normal file
View File

@@ -0,0 +1,16 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package plexgo
type Plex struct {
Tv *Tv
sdkConfiguration sdkConfiguration
}
func newPlex(sdkConfig sdkConfiguration) *Plex {
return &Plex{
sdkConfiguration: sdkConfig,
Tv: newTv(sdkConfig),
}
}

View File

@@ -97,6 +97,7 @@ type PlexAPI struct {
// Submit logs to the Log Handler for Plex Media Server // Submit logs to the Log Handler for Plex Media Server
// //
Log *Log Log *Log
Plex *Plex
// Playlists are ordered collections of media. They can be dumb (just a list of media) or smart (based on a media query, such as "all albums from 2017"). // Playlists are ordered collections of media. They can be dumb (just a list of media) or smart (based on a media query, such as "all albums from 2017").
// They can be organized in (optionally nesting) folders. // They can be organized in (optionally nesting) folders.
// Retrieving a playlist, or its items, will trigger a refresh of its metadata. // Retrieving a playlist, or its items, will trigger a refresh of its metadata.
@@ -251,9 +252,9 @@ func New(opts ...SDKOption) *PlexAPI {
sdkConfiguration: sdkConfiguration{ sdkConfiguration: sdkConfiguration{
Language: "go", Language: "go",
OpenAPIDocVersion: "0.0.3", OpenAPIDocVersion: "0.0.3",
SDKVersion: "0.1.3", SDKVersion: "0.2.0",
GenVersion: "2.237.3", GenVersion: "2.239.4",
UserAgent: "speakeasy-sdk/go 0.1.3 2.237.3 0.0.3 github.com/LukeHagar/plexgo", UserAgent: "speakeasy-sdk/go 0.2.0 2.239.4 0.0.3 github.com/LukeHagar/plexgo",
ServerDefaults: []map[string]string{ ServerDefaults: []map[string]string{
{ {
"protocol": "http", "protocol": "http",
@@ -295,6 +296,8 @@ func New(opts ...SDKOption) *PlexAPI {
sdk.Log = newLog(sdk.sdkConfiguration) sdk.Log = newLog(sdk.sdkConfiguration)
sdk.Plex = newPlex(sdk.sdkConfiguration)
sdk.Playlists = newPlaylists(sdk.sdkConfiguration) sdk.Playlists = newPlaylists(sdk.sdkConfiguration)
sdk.Security = newSecurity(sdk.sdkConfiguration) sdk.Security = newSecurity(sdk.sdkConfiguration)

207
tv.go Normal file
View File

@@ -0,0 +1,207 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package plexgo
import (
"bytes"
"context"
"fmt"
"github.com/LukeHagar/plexgo/internal/utils"
"github.com/LukeHagar/plexgo/models/operations"
"github.com/LukeHagar/plexgo/models/sdkerrors"
"io"
"net/http"
"strings"
)
type Tv struct {
sdkConfiguration sdkConfiguration
}
func newTv(sdkConfig sdkConfiguration) *Tv {
return &Tv{
sdkConfiguration: sdkConfig,
}
}
// GetPin - Get a Pin
// Retrieve a Pin from Plex.tv for authentication flows
func (s *Tv) GetPin(ctx context.Context, xPlexClientIdentifier string, strong *bool, opts ...operations.Option) (*operations.GetPinResponse, error) {
request := operations.GetPinRequest{
XPlexClientIdentifier: xPlexClientIdentifier,
Strong: strong,
}
o := operations.Options{}
supportedOptions := []string{
operations.SupportedOptionServerURL,
}
for _, opt := range opts {
if err := opt(&o, supportedOptions...); err != nil {
return nil, fmt.Errorf("error applying option: %w", err)
}
}
baseURL := utils.ReplaceParameters(operations.GetPinServerList[0], map[string]string{})
if o.ServerURL != nil {
baseURL = *o.ServerURL
}
url := strings.TrimSuffix(baseURL, "/") + "/pins"
req, err := http.NewRequestWithContext(ctx, "POST", url, nil)
if err != nil {
return nil, fmt.Errorf("error creating request: %w", err)
}
req.Header.Set("Accept", "application/json")
req.Header.Set("user-agent", s.sdkConfiguration.UserAgent)
utils.PopulateHeaders(ctx, req, request)
if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil {
return nil, fmt.Errorf("error populating query params: %w", err)
}
client := s.sdkConfiguration.SecurityClient
httpRes, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %w", err)
}
if httpRes == nil {
return nil, fmt.Errorf("error sending request: no response")
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetPinResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
RawResponse: httpRes,
}
rawBody, err := io.ReadAll(httpRes.Body)
if err != nil {
return nil, fmt.Errorf("error reading response body: %w", err)
}
httpRes.Body.Close()
httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody))
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out operations.GetPinResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
res.Object = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
case httpRes.StatusCode == 400:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out sdkerrors.GetPinResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
fallthrough
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
}
// GetToken - Get Access Token
// Retrieve an Access Token from Plex.tv after the Pin has already been authenticated
func (s *Tv) GetToken(ctx context.Context, pinID string, xPlexClientIdentifier string, opts ...operations.Option) (*operations.GetTokenResponse, error) {
request := operations.GetTokenRequest{
PinID: pinID,
XPlexClientIdentifier: xPlexClientIdentifier,
}
o := operations.Options{}
supportedOptions := []string{
operations.SupportedOptionServerURL,
}
for _, opt := range opts {
if err := opt(&o, supportedOptions...); err != nil {
return nil, fmt.Errorf("error applying option: %w", err)
}
}
baseURL := utils.ReplaceParameters(operations.GetTokenServerList[0], map[string]string{})
if o.ServerURL != nil {
baseURL = *o.ServerURL
}
url, err := utils.GenerateURL(ctx, baseURL, "/pins/{pinID}", request, nil)
if err != nil {
return nil, fmt.Errorf("error generating URL: %w", err)
}
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
return nil, fmt.Errorf("error creating request: %w", err)
}
req.Header.Set("Accept", "application/json")
req.Header.Set("user-agent", s.sdkConfiguration.UserAgent)
utils.PopulateHeaders(ctx, req, request)
client := s.sdkConfiguration.SecurityClient
httpRes, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("error sending request: %w", err)
}
if httpRes == nil {
return nil, fmt.Errorf("error sending request: no response")
}
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetTokenResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
RawResponse: httpRes,
}
rawBody, err := io.ReadAll(httpRes.Body)
if err != nil {
return nil, fmt.Errorf("error reading response body: %w", err)
}
httpRes.Body.Close()
httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody))
switch {
case httpRes.StatusCode == 200:
case httpRes.StatusCode == 400:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out sdkerrors.GetTokenResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
out.RawResponse = httpRes
return nil, &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500:
fallthrough
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600:
return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes)
}
return res, nil
}