From e0b73fab9aa275f7d6382f7c20a28d01ed873567 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Sat, 22 Jun 2024 00:19:59 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.314.2 --- .speakeasy/gen.lock | 17 +- .speakeasy/gen.yaml | 2 +- .speakeasy/workflow.lock | 10 +- README.md | 8 +- RELEASES.md | 12 +- docs/index.md | 2 +- examples/provider/provider.tf | 2 +- internal/sdk/internal/globals/globals.go | 6 +- internal/sdk/internal/utils/contenttype.go | 4 + internal/sdk/library.go | 102 ++++ .../operations/getbandwidthstatistics.go | 316 +++++++++++ .../sdk/models/operations/getlibraryitems.go | 78 ++- .../models/operations/getmetadatachildren.go | 10 + internal/sdk/models/operations/getpin.go | 10 +- .../operations/getresourcesstatistics.go | 190 +++++++ .../models/operations/getsessionhistory.go | 49 ++ internal/sdk/models/operations/getsessions.go | 12 +- internal/sdk/models/operations/gettoken.go | 6 +- .../models/operations/gettopwatchedcontent.go | 530 ++++++++++++++++++ .../sdk/models/operations/getwatchlist.go | 24 +- internal/sdk/playlists.go | 2 +- internal/sdk/plexapi.go | 7 +- internal/sdk/server.go | 4 +- internal/sdk/sessions.go | 6 +- internal/sdk/statistics.go | 214 +++++++ 25 files changed, 1565 insertions(+), 58 deletions(-) create mode 100644 internal/sdk/models/operations/getbandwidthstatistics.go create mode 100644 internal/sdk/models/operations/getresourcesstatistics.go create mode 100644 internal/sdk/models/operations/gettopwatchedcontent.go diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 8b22edb..ef7816b 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: e742591b-391d-4f4e-8484-d01a093b32ec management: - docChecksum: 37654ea0982ab5e87a9a9576014c9d19 + docChecksum: e73920abd3a55e8d249592f2e3090574 docVersion: 0.0.3 - speakeasyVersion: 1.308.1 - generationVersion: 2.342.6 - releaseVersion: 0.16.0 - configChecksum: 164b8ea4eba6b7cd1405bc6fda363cba + speakeasyVersion: 1.314.2 + generationVersion: 2.349.6 + releaseVersion: 0.17.0 + configChecksum: 1ad7c7df83d2c81fab1bf53c153bcd1e repoURL: https://github.com/LukeHagar/plexterraform.git repoSubDirectory: . published: true @@ -14,13 +14,15 @@ features: terraform: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.4 - core: 3.21.3 + core: 3.21.4 globalSecurity: 2.81.6 globalServerURLs: 2.82.1 globals: 2.82.1 methodServerURLs: 2.82.1 nameOverrides: 2.81.2 + nullables: 0.0.0 typeOverrides: 2.81.1 + unions: 2.81.15 generatedFiles: - internal/sdk/server.go - internal/sdk/media.go @@ -94,6 +96,7 @@ generatedFiles: - internal/sdk/models/operations/searchlibrary.go - internal/sdk/models/operations/getmetadata.go - internal/sdk/models/operations/getmetadatachildren.go + - internal/sdk/models/operations/gettopwatchedcontent.go - internal/sdk/models/operations/getondeck.go - internal/sdk/models/operations/logline.go - internal/sdk/models/operations/logmultiline.go @@ -110,6 +113,8 @@ generatedFiles: - internal/sdk/models/operations/gettransienttoken.go - internal/sdk/models/operations/getsourceconnectioninformation.go - internal/sdk/models/operations/getstatistics.go + - internal/sdk/models/operations/getresourcesstatistics.go + - internal/sdk/models/operations/getbandwidthstatistics.go - internal/sdk/models/operations/getsessions.go - internal/sdk/models/operations/getsessionhistory.go - internal/sdk/models/operations/gettranscodesessions.go diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 1bcb575..68fef4b 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false terraform: - version: 0.16.0 + version: 0.17.0 additionalDataSources: [] additionalDependencies: {} additionalResources: [] diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index cac2ed4..15aa126 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.308.1 +speakeasyVersion: 1.314.2 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:632b003c96a45adc5055cf572c4f68c55bc30ef2c1e78f117c8252a940fe2aac - sourceBlobDigest: sha256:73da4378fd215db15f6cbb427c72561917d73a0b910691e12f857e24ac391182 + sourceRevisionDigest: sha256:dd6e54ab10e659fa2065d4f476d3d2d047daf72f8c426a70717b0bd48a500d4a + sourceBlobDigest: sha256:b1f025c46f350b018ba28d042a40be9548831d17fcef58449187038ec63ce097 tags: - latest - main @@ -11,8 +11,8 @@ targets: plexterraform: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:632b003c96a45adc5055cf572c4f68c55bc30ef2c1e78f117c8252a940fe2aac - sourceBlobDigest: sha256:73da4378fd215db15f6cbb427c72561917d73a0b910691e12f857e24ac391182 + sourceRevisionDigest: sha256:dd6e54ab10e659fa2065d4f476d3d2d047daf72f8c426a70717b0bd48a500d4a + sourceBlobDigest: sha256:b1f025c46f350b018ba28d042a40be9548831d17fcef58449187038ec63ce097 outLocation: /github/workspace/repo workflow: workflowVersion: 1.0.0 diff --git a/README.md b/README.md index 9f38561..9ffbea1 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ terraform { required_providers { PlexAPI = { source = "LukeHagar/PlexAPI" - version = "0.16.0" + version = "0.17.0" } } } @@ -102,18 +102,18 @@ TF_REATTACH_PROVIDERS=... terraform apply ## 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. +A parameter is configured globally. This parameter may 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 `"Postman"` 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. +The following global parameter is available. | Name | Type | Required | Description | | ---- | ---- |:--------:| ----------- | -| XPlexClientIdentifier | string | ✔️ | The unique identifier for the client application +| 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) | diff --git a/RELEASES.md b/RELEASES.md index 03afc6b..f56a56c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -312,4 +312,14 @@ Based on: ### Generated - [terraform v0.16.0] . ### Releases -- [Terraform v0.16.0] https://registry.terraform.io/providers/LukeHagar/PlexAPI/0.16.0 - . \ No newline at end of file +- [Terraform v0.16.0] https://registry.terraform.io/providers/LukeHagar/PlexAPI/0.16.0 - . + +## 2024-06-22 00:18:49 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.314.2 (2.349.6) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v0.17.0] . +### Releases +- [Terraform v0.17.0] https://registry.terraform.io/providers/LukeHagar/PlexAPI/0.17.0 - . \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 8445010..31762dc 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ terraform { required_providers { PlexAPI = { source = "LukeHagar/PlexAPI" - version = "0.16.0" + version = "0.17.0" } } } diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 7963503..00af2c3 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { PlexAPI = { source = "LukeHagar/PlexAPI" - version = "0.16.0" + version = "0.17.0" } } } diff --git a/internal/sdk/internal/globals/globals.go b/internal/sdk/internal/globals/globals.go index c53a33a..c93e2de 100644 --- a/internal/sdk/internal/globals/globals.go +++ b/internal/sdk/internal/globals/globals.go @@ -7,12 +7,12 @@ type Globals struct { // This is used to track the client application and its usage // (UUID, serial number, or other number unique per device) // - XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` + XPlexClientIdentifier *string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` } -func (o *Globals) GetXPlexClientIdentifier() string { +func (o *Globals) GetXPlexClientIdentifier() *string { if o == nil { - return "" + return nil } return o.XPlexClientIdentifier } diff --git a/internal/sdk/internal/utils/contenttype.go b/internal/sdk/internal/utils/contenttype.go index 8ed13e2..763f2d6 100644 --- a/internal/sdk/internal/utils/contenttype.go +++ b/internal/sdk/internal/utils/contenttype.go @@ -9,6 +9,10 @@ import ( ) func MatchContentType(contentType string, pattern string) bool { + if contentType == "" { + contentType = "application/octet-stream" + } + if contentType == pattern || pattern == "*" || pattern == "*/*" { return true } diff --git a/internal/sdk/library.go b/internal/sdk/library.go index 0de4ea3..b9508f0 100644 --- a/internal/sdk/library.go +++ b/internal/sdk/library.go @@ -614,6 +614,10 @@ func (s *Library) GetLibraryItems(ctx context.Context, request operations.GetLib req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { return nil, err } @@ -1037,6 +1041,10 @@ func (s *Library) GetMetadataChildren(ctx context.Context, request operations.Ge req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { return nil, err } @@ -1117,6 +1125,100 @@ func (s *Library) GetMetadataChildren(ctx context.Context, request operations.Ge } +// GetTopWatchedContent - Get Top Watched Content +// This endpoint will return the top watched content from libraries of a certain type +func (s *Library) GetTopWatchedContent(ctx context.Context, request operations.GetTopWatchedContentRequest) (*operations.GetTopWatchedContentResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getTopWatchedContent", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/library/all/top") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + + res := &operations.GetTopWatchedContentResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + 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(httpRes.Header.Get("Content-Type"), `application/json`): + var out operations.GetTopWatchedContentResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Object = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + // GetOnDeck - Get On Deck // This endpoint will return the on deck content. func (s *Library) GetOnDeck(ctx context.Context) (*operations.GetOnDeckResponse, error) { diff --git a/internal/sdk/models/operations/getbandwidthstatistics.go b/internal/sdk/models/operations/getbandwidthstatistics.go new file mode 100644 index 0000000..65d1e75 --- /dev/null +++ b/internal/sdk/models/operations/getbandwidthstatistics.go @@ -0,0 +1,316 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "net/http" +) + +type GetBandwidthStatisticsRequest struct { + // The timespan to retrieve statistics for + // the exact meaning of this parameter is not known + // + Timespan *int64 `queryParam:"style=form,explode=true,name=Timespan"` +} + +func (o *GetBandwidthStatisticsRequest) GetTimespan() *int64 { + if o == nil { + return nil + } + return o.Timespan +} + +type GetBandwidthStatisticsErrors struct { + Code *float64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Status *float64 `json:"status,omitempty"` +} + +func (o *GetBandwidthStatisticsErrors) GetCode() *float64 { + if o == nil { + return nil + } + return o.Code +} + +func (o *GetBandwidthStatisticsErrors) GetMessage() *string { + if o == nil { + return nil + } + return o.Message +} + +func (o *GetBandwidthStatisticsErrors) GetStatus() *float64 { + if o == nil { + return nil + } + return o.Status +} + +// GetBandwidthStatisticsStatisticsResponseBody - Unauthorized - Returned if the X-Plex-Token is missing from the header or query. +type GetBandwidthStatisticsStatisticsResponseBody struct { + Errors []GetBandwidthStatisticsErrors `json:"errors,omitempty"` +} + +func (o *GetBandwidthStatisticsStatisticsResponseBody) GetErrors() []GetBandwidthStatisticsErrors { + if o == nil { + return nil + } + return o.Errors +} + +type GetBandwidthStatisticsDevice struct { + ID *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Platform *string `json:"platform,omitempty"` + ClientIdentifier *string `json:"clientIdentifier,omitempty"` + CreatedAt *int `json:"createdAt,omitempty"` +} + +func (o *GetBandwidthStatisticsDevice) GetID() *int { + if o == nil { + return nil + } + return o.ID +} + +func (o *GetBandwidthStatisticsDevice) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *GetBandwidthStatisticsDevice) GetPlatform() *string { + if o == nil { + return nil + } + return o.Platform +} + +func (o *GetBandwidthStatisticsDevice) GetClientIdentifier() *string { + if o == nil { + return nil + } + return o.ClientIdentifier +} + +func (o *GetBandwidthStatisticsDevice) GetCreatedAt() *int { + if o == nil { + return nil + } + return o.CreatedAt +} + +type GetBandwidthStatisticsAccount struct { + ID *int `json:"id,omitempty"` + Key *string `json:"key,omitempty"` + Name *string `json:"name,omitempty"` + DefaultAudioLanguage *string `json:"defaultAudioLanguage,omitempty"` + AutoSelectAudio *bool `json:"autoSelectAudio,omitempty"` + DefaultSubtitleLanguage *string `json:"defaultSubtitleLanguage,omitempty"` + SubtitleMode *int `json:"subtitleMode,omitempty"` + Thumb *string `json:"thumb,omitempty"` +} + +func (o *GetBandwidthStatisticsAccount) GetID() *int { + if o == nil { + return nil + } + return o.ID +} + +func (o *GetBandwidthStatisticsAccount) GetKey() *string { + if o == nil { + return nil + } + return o.Key +} + +func (o *GetBandwidthStatisticsAccount) GetName() *string { + if o == nil { + return nil + } + return o.Name +} + +func (o *GetBandwidthStatisticsAccount) GetDefaultAudioLanguage() *string { + if o == nil { + return nil + } + return o.DefaultAudioLanguage +} + +func (o *GetBandwidthStatisticsAccount) GetAutoSelectAudio() *bool { + if o == nil { + return nil + } + return o.AutoSelectAudio +} + +func (o *GetBandwidthStatisticsAccount) GetDefaultSubtitleLanguage() *string { + if o == nil { + return nil + } + return o.DefaultSubtitleLanguage +} + +func (o *GetBandwidthStatisticsAccount) GetSubtitleMode() *int { + if o == nil { + return nil + } + return o.SubtitleMode +} + +func (o *GetBandwidthStatisticsAccount) GetThumb() *string { + if o == nil { + return nil + } + return o.Thumb +} + +type StatisticsBandwidth struct { + AccountID *int `json:"accountID,omitempty"` + DeviceID *int `json:"deviceID,omitempty"` + Timespan *int64 `json:"timespan,omitempty"` + At *int `json:"at,omitempty"` + Lan *bool `json:"lan,omitempty"` + Bytes *int64 `json:"bytes,omitempty"` +} + +func (o *StatisticsBandwidth) GetAccountID() *int { + if o == nil { + return nil + } + return o.AccountID +} + +func (o *StatisticsBandwidth) GetDeviceID() *int { + if o == nil { + return nil + } + return o.DeviceID +} + +func (o *StatisticsBandwidth) GetTimespan() *int64 { + if o == nil { + return nil + } + return o.Timespan +} + +func (o *StatisticsBandwidth) GetAt() *int { + if o == nil { + return nil + } + return o.At +} + +func (o *StatisticsBandwidth) GetLan() *bool { + if o == nil { + return nil + } + return o.Lan +} + +func (o *StatisticsBandwidth) GetBytes() *int64 { + if o == nil { + return nil + } + return o.Bytes +} + +type GetBandwidthStatisticsMediaContainer struct { + Size *int `json:"size,omitempty"` + Device []GetBandwidthStatisticsDevice `json:"Device,omitempty"` + Account []GetBandwidthStatisticsAccount `json:"Account,omitempty"` + StatisticsBandwidth []StatisticsBandwidth `json:"StatisticsBandwidth,omitempty"` +} + +func (o *GetBandwidthStatisticsMediaContainer) GetSize() *int { + if o == nil { + return nil + } + return o.Size +} + +func (o *GetBandwidthStatisticsMediaContainer) GetDevice() []GetBandwidthStatisticsDevice { + if o == nil { + return nil + } + return o.Device +} + +func (o *GetBandwidthStatisticsMediaContainer) GetAccount() []GetBandwidthStatisticsAccount { + if o == nil { + return nil + } + return o.Account +} + +func (o *GetBandwidthStatisticsMediaContainer) GetStatisticsBandwidth() []StatisticsBandwidth { + if o == nil { + return nil + } + return o.StatisticsBandwidth +} + +// GetBandwidthStatisticsResponseBody - Bandwidth Statistics +type GetBandwidthStatisticsResponseBody struct { + MediaContainer *GetBandwidthStatisticsMediaContainer `json:"MediaContainer,omitempty"` +} + +func (o *GetBandwidthStatisticsResponseBody) GetMediaContainer() *GetBandwidthStatisticsMediaContainer { + if o == nil { + return nil + } + return o.MediaContainer +} + +type GetBandwidthStatisticsResponse 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 + // Bandwidth Statistics + TwoHundredApplicationJSONObject *GetBandwidthStatisticsResponseBody + // Unauthorized - Returned if the X-Plex-Token is missing from the header or query. + FourHundredAndOneApplicationJSONObject *GetBandwidthStatisticsStatisticsResponseBody +} + +func (o *GetBandwidthStatisticsResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *GetBandwidthStatisticsResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *GetBandwidthStatisticsResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} + +func (o *GetBandwidthStatisticsResponse) GetTwoHundredApplicationJSONObject() *GetBandwidthStatisticsResponseBody { + if o == nil { + return nil + } + return o.TwoHundredApplicationJSONObject +} + +func (o *GetBandwidthStatisticsResponse) GetFourHundredAndOneApplicationJSONObject() *GetBandwidthStatisticsStatisticsResponseBody { + if o == nil { + return nil + } + return o.FourHundredAndOneApplicationJSONObject +} diff --git a/internal/sdk/models/operations/getlibraryitems.go b/internal/sdk/models/operations/getlibraryitems.go index d69765c..b0a8bcc 100644 --- a/internal/sdk/models/operations/getlibraryitems.go +++ b/internal/sdk/models/operations/getlibraryitems.go @@ -4,6 +4,7 @@ package operations import ( "encoding/json" + "errors" "fmt" "github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk/internal/utils" "github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk/types" @@ -93,6 +94,9 @@ type GetLibraryItemsRequest struct { SectionID any `pathParam:"style=simple,explode=false,name=sectionId"` // A key representing a specific tag within the section. Tag Tag `pathParam:"style=simple,explode=false,name=tag"` + // Adds the Guids object to the response + // + IncludeGuids *int64 `queryParam:"style=form,explode=true,name=includeGuids"` } func (o *GetLibraryItemsRequest) GetSectionID() any { @@ -109,6 +113,13 @@ func (o *GetLibraryItemsRequest) GetTag() Tag { return o.Tag } +func (o *GetLibraryItemsRequest) GetIncludeGuids() *int64 { + if o == nil { + return nil + } + return o.IncludeGuids +} + type GetLibraryItemsErrors struct { Code *float64 `json:"code,omitempty"` Message *string `json:"message,omitempty"` @@ -148,6 +159,69 @@ func (o *GetLibraryItemsLibraryResponseBody) GetErrors() []GetLibraryItemsErrors return o.Errors } +type LibrarySectionIDType string + +const ( + LibrarySectionIDTypeInteger LibrarySectionIDType = "integer" + LibrarySectionIDTypeStr LibrarySectionIDType = "str" +) + +type LibrarySectionID struct { + Integer *int64 + Str *string + + Type LibrarySectionIDType +} + +func CreateLibrarySectionIDInteger(integer int64) LibrarySectionID { + typ := LibrarySectionIDTypeInteger + + return LibrarySectionID{ + Integer: &integer, + Type: typ, + } +} + +func CreateLibrarySectionIDStr(str string) LibrarySectionID { + typ := LibrarySectionIDTypeStr + + return LibrarySectionID{ + Str: &str, + Type: typ, + } +} + +func (u *LibrarySectionID) UnmarshalJSON(data []byte) error { + + var integer int64 = int64(0) + if err := utils.UnmarshalJSON(data, &integer, "", true, true); err == nil { + u.Integer = &integer + u.Type = LibrarySectionIDTypeInteger + return nil + } + + var str string = "" + if err := utils.UnmarshalJSON(data, &str, "", true, true); err == nil { + u.Str = &str + u.Type = LibrarySectionIDTypeStr + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for LibrarySectionID", string(data)) +} + +func (u LibrarySectionID) MarshalJSON() ([]byte, error) { + if u.Integer != nil { + return utils.MarshalJSON(u.Integer, "", true) + } + + if u.Str != nil { + return utils.MarshalJSON(u.Str, "", true) + } + + return nil, errors.New("could not marshal union type LibrarySectionID: all fields are null") +} + type GetLibraryItemsPart struct { ID *int `json:"id,omitempty"` Key *string `json:"key,omitempty"` @@ -852,7 +926,7 @@ type GetLibraryItemsMediaContainer struct { AllowSync *bool `json:"allowSync,omitempty"` Art *string `json:"art,omitempty"` Identifier *string `json:"identifier,omitempty"` - LibrarySectionID *int `json:"librarySectionID,omitempty"` + LibrarySectionID *LibrarySectionID `json:"librarySectionID,omitempty"` LibrarySectionTitle *string `json:"librarySectionTitle,omitempty"` LibrarySectionUUID *string `json:"librarySectionUUID,omitempty"` MediaTagPrefix *string `json:"mediaTagPrefix,omitempty"` @@ -894,7 +968,7 @@ func (o *GetLibraryItemsMediaContainer) GetIdentifier() *string { return o.Identifier } -func (o *GetLibraryItemsMediaContainer) GetLibrarySectionID() *int { +func (o *GetLibraryItemsMediaContainer) GetLibrarySectionID() *LibrarySectionID { if o == nil { return nil } diff --git a/internal/sdk/models/operations/getmetadatachildren.go b/internal/sdk/models/operations/getmetadatachildren.go index 7ea9c09..fa3392e 100644 --- a/internal/sdk/models/operations/getmetadatachildren.go +++ b/internal/sdk/models/operations/getmetadatachildren.go @@ -9,6 +9,9 @@ import ( type GetMetadataChildrenRequest struct { // the id of the library item to return the children of. RatingKey float64 `pathParam:"style=simple,explode=false,name=ratingKey"` + // Adds additional elements to the response. Supported types are (Stream) + // + IncludeElements *string `queryParam:"style=form,explode=true,name=includeElements"` } func (o *GetMetadataChildrenRequest) GetRatingKey() float64 { @@ -18,6 +21,13 @@ func (o *GetMetadataChildrenRequest) GetRatingKey() float64 { return o.RatingKey } +func (o *GetMetadataChildrenRequest) GetIncludeElements() *string { + if o == nil { + return nil + } + return o.IncludeElements +} + type GetMetadataChildrenErrors struct { Code *float64 `json:"code,omitempty"` Message *string `json:"message,omitempty"` diff --git a/internal/sdk/models/operations/getpin.go b/internal/sdk/models/operations/getpin.go index a4b4829..2ecfcd7 100644 --- a/internal/sdk/models/operations/getpin.go +++ b/internal/sdk/models/operations/getpin.go @@ -17,12 +17,12 @@ type GetPinGlobals struct { // This is used to track the client application and its usage // (UUID, serial number, or other number unique per device) // - XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` + XPlexClientIdentifier *string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` } -func (o *GetPinGlobals) GetXPlexClientIdentifier() string { +func (o *GetPinGlobals) GetXPlexClientIdentifier() *string { if o == nil { - return "" + return nil } return o.XPlexClientIdentifier } @@ -215,7 +215,7 @@ type GetPinResponseBody struct { CreatedAt *time.Time `json:"createdAt,omitempty"` ExpiresAt *time.Time `json:"expiresAt,omitempty"` AuthToken *string `json:"authToken,omitempty"` - NewRegistration *string `json:"newRegistration,omitempty"` + NewRegistration *bool `json:"newRegistration,omitempty"` } func (g GetPinResponseBody) MarshalJSON() ([]byte, error) { @@ -306,7 +306,7 @@ func (o *GetPinResponseBody) GetAuthToken() *string { return o.AuthToken } -func (o *GetPinResponseBody) GetNewRegistration() *string { +func (o *GetPinResponseBody) GetNewRegistration() *bool { if o == nil { return nil } diff --git a/internal/sdk/models/operations/getresourcesstatistics.go b/internal/sdk/models/operations/getresourcesstatistics.go new file mode 100644 index 0000000..f5a13fe --- /dev/null +++ b/internal/sdk/models/operations/getresourcesstatistics.go @@ -0,0 +1,190 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "net/http" +) + +type GetResourcesStatisticsRequest struct { + // The timespan to retrieve statistics for + // the exact meaning of this parameter is not known + // + Timespan *int64 `queryParam:"style=form,explode=true,name=Timespan"` +} + +func (o *GetResourcesStatisticsRequest) GetTimespan() *int64 { + if o == nil { + return nil + } + return o.Timespan +} + +type GetResourcesStatisticsErrors struct { + Code *float64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Status *float64 `json:"status,omitempty"` +} + +func (o *GetResourcesStatisticsErrors) GetCode() *float64 { + if o == nil { + return nil + } + return o.Code +} + +func (o *GetResourcesStatisticsErrors) GetMessage() *string { + if o == nil { + return nil + } + return o.Message +} + +func (o *GetResourcesStatisticsErrors) GetStatus() *float64 { + if o == nil { + return nil + } + return o.Status +} + +// GetResourcesStatisticsStatisticsResponseBody - Unauthorized - Returned if the X-Plex-Token is missing from the header or query. +type GetResourcesStatisticsStatisticsResponseBody struct { + Errors []GetResourcesStatisticsErrors `json:"errors,omitempty"` +} + +func (o *GetResourcesStatisticsStatisticsResponseBody) GetErrors() []GetResourcesStatisticsErrors { + if o == nil { + return nil + } + return o.Errors +} + +type StatisticsResources struct { + Timespan *int64 `json:"timespan,omitempty"` + At *int64 `json:"at,omitempty"` + HostCPUUtilization *float32 `json:"hostCpuUtilization,omitempty"` + ProcessCPUUtilization *float32 `json:"processCpuUtilization,omitempty"` + HostMemoryUtilization *float32 `json:"hostMemoryUtilization,omitempty"` + ProcessMemoryUtilization *float32 `json:"processMemoryUtilization,omitempty"` +} + +func (o *StatisticsResources) GetTimespan() *int64 { + if o == nil { + return nil + } + return o.Timespan +} + +func (o *StatisticsResources) GetAt() *int64 { + if o == nil { + return nil + } + return o.At +} + +func (o *StatisticsResources) GetHostCPUUtilization() *float32 { + if o == nil { + return nil + } + return o.HostCPUUtilization +} + +func (o *StatisticsResources) GetProcessCPUUtilization() *float32 { + if o == nil { + return nil + } + return o.ProcessCPUUtilization +} + +func (o *StatisticsResources) GetHostMemoryUtilization() *float32 { + if o == nil { + return nil + } + return o.HostMemoryUtilization +} + +func (o *StatisticsResources) GetProcessMemoryUtilization() *float32 { + if o == nil { + return nil + } + return o.ProcessMemoryUtilization +} + +type GetResourcesStatisticsMediaContainer struct { + Size *int `json:"size,omitempty"` + StatisticsResources []StatisticsResources `json:"StatisticsResources,omitempty"` +} + +func (o *GetResourcesStatisticsMediaContainer) GetSize() *int { + if o == nil { + return nil + } + return o.Size +} + +func (o *GetResourcesStatisticsMediaContainer) GetStatisticsResources() []StatisticsResources { + if o == nil { + return nil + } + return o.StatisticsResources +} + +// GetResourcesStatisticsResponseBody - Resource Statistics +type GetResourcesStatisticsResponseBody struct { + MediaContainer *GetResourcesStatisticsMediaContainer `json:"MediaContainer,omitempty"` +} + +func (o *GetResourcesStatisticsResponseBody) GetMediaContainer() *GetResourcesStatisticsMediaContainer { + if o == nil { + return nil + } + return o.MediaContainer +} + +type GetResourcesStatisticsResponse 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 + // Resource Statistics + TwoHundredApplicationJSONObject *GetResourcesStatisticsResponseBody + // Unauthorized - Returned if the X-Plex-Token is missing from the header or query. + FourHundredAndOneApplicationJSONObject *GetResourcesStatisticsStatisticsResponseBody +} + +func (o *GetResourcesStatisticsResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *GetResourcesStatisticsResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *GetResourcesStatisticsResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} + +func (o *GetResourcesStatisticsResponse) GetTwoHundredApplicationJSONObject() *GetResourcesStatisticsResponseBody { + if o == nil { + return nil + } + return o.TwoHundredApplicationJSONObject +} + +func (o *GetResourcesStatisticsResponse) GetFourHundredAndOneApplicationJSONObject() *GetResourcesStatisticsStatisticsResponseBody { + if o == nil { + return nil + } + return o.FourHundredAndOneApplicationJSONObject +} diff --git a/internal/sdk/models/operations/getsessionhistory.go b/internal/sdk/models/operations/getsessionhistory.go index 37d4334..4486113 100644 --- a/internal/sdk/models/operations/getsessionhistory.go +++ b/internal/sdk/models/operations/getsessionhistory.go @@ -8,6 +8,55 @@ import ( "net/http" ) +// Filter - Filters content by field and direction/equality +// (Unknown if viewedAt is the only supported column) +type Filter struct { +} + +type GetSessionHistoryRequest struct { + // Sorts the results by the specified field followed by the direction (asc, desc) + // + Sort *string `queryParam:"style=form,explode=true,name=sort"` + // Filter results by those that are related to a specific users id + // + AccountID *int64 `queryParam:"style=form,explode=true,name=accountId"` + // Filters content by field and direction/equality + // (Unknown if viewedAt is the only supported column) + // + Filter *Filter `queryParam:"style=form,explode=true,name=filter"` + // Filters the results based on the id of a valid library section + // + LibrarySectionID *int64 `queryParam:"style=form,explode=true,name=librarySectionID"` +} + +func (o *GetSessionHistoryRequest) GetSort() *string { + if o == nil { + return nil + } + return o.Sort +} + +func (o *GetSessionHistoryRequest) GetAccountID() *int64 { + if o == nil { + return nil + } + return o.AccountID +} + +func (o *GetSessionHistoryRequest) GetFilter() *Filter { + if o == nil { + return nil + } + return o.Filter +} + +func (o *GetSessionHistoryRequest) GetLibrarySectionID() *int64 { + if o == nil { + return nil + } + return o.LibrarySectionID +} + type GetSessionHistoryErrors struct { Code *float64 `json:"code,omitempty"` Message *string `json:"message,omitempty"` diff --git a/internal/sdk/models/operations/getsessions.go b/internal/sdk/models/operations/getsessions.go index 6e36e3c..3529000 100644 --- a/internal/sdk/models/operations/getsessions.go +++ b/internal/sdk/models/operations/getsessions.go @@ -358,27 +358,27 @@ func (o *GetSessionsMedia) GetPart() []GetSessionsPart { return o.Part } -type User struct { +type GetSessionsUser struct { ID *string `json:"id,omitempty"` Thumb *string `json:"thumb,omitempty"` Title *string `json:"title,omitempty"` } -func (o *User) GetID() *string { +func (o *GetSessionsUser) GetID() *string { if o == nil { return nil } return o.ID } -func (o *User) GetThumb() *string { +func (o *GetSessionsUser) GetThumb() *string { if o == nil { return nil } return o.Thumb } -func (o *User) GetTitle() *string { +func (o *GetSessionsUser) GetTitle() *string { if o == nil { return nil } @@ -570,7 +570,7 @@ type GetSessionsMetadata struct { UpdatedAt *int `json:"updatedAt,omitempty"` ViewOffset *int `json:"viewOffset,omitempty"` Media []GetSessionsMedia `json:"Media,omitempty"` - User *User `json:"User,omitempty"` + User *GetSessionsUser `json:"User,omitempty"` Player *Player `json:"Player,omitempty"` Session *Session `json:"Session,omitempty"` } @@ -813,7 +813,7 @@ func (o *GetSessionsMetadata) GetMedia() []GetSessionsMedia { return o.Media } -func (o *GetSessionsMetadata) GetUser() *User { +func (o *GetSessionsMetadata) GetUser() *GetSessionsUser { if o == nil { return nil } diff --git a/internal/sdk/models/operations/gettoken.go b/internal/sdk/models/operations/gettoken.go index 530dd97..37de051 100644 --- a/internal/sdk/models/operations/gettoken.go +++ b/internal/sdk/models/operations/gettoken.go @@ -17,12 +17,12 @@ type GetTokenGlobals struct { // This is used to track the client application and its usage // (UUID, serial number, or other number unique per device) // - XPlexClientIdentifier string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` + XPlexClientIdentifier *string `header:"style=simple,explode=false,name=X-Plex-Client-Identifier"` } -func (o *GetTokenGlobals) GetXPlexClientIdentifier() string { +func (o *GetTokenGlobals) GetXPlexClientIdentifier() *string { if o == nil { - return "" + return nil } return o.XPlexClientIdentifier } diff --git a/internal/sdk/models/operations/gettopwatchedcontent.go b/internal/sdk/models/operations/gettopwatchedcontent.go new file mode 100644 index 0000000..4252f84 --- /dev/null +++ b/internal/sdk/models/operations/gettopwatchedcontent.go @@ -0,0 +1,530 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk/internal/utils" + "github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk/types" + "net/http" +) + +type GetTopWatchedContentRequest struct { + // the library type (1 - movies, 2 - shows, 3 - music) + Type int64 `queryParam:"style=form,explode=true,name=type"` + // Adds the Guids object to the response + // + IncludeGuids *int64 `queryParam:"style=form,explode=true,name=includeGuids"` +} + +func (o *GetTopWatchedContentRequest) GetType() int64 { + if o == nil { + return 0 + } + return o.Type +} + +func (o *GetTopWatchedContentRequest) GetIncludeGuids() *int64 { + if o == nil { + return nil + } + return o.IncludeGuids +} + +type GetTopWatchedContentGenre struct { + ID *int `json:"id,omitempty"` + Filter *string `json:"filter,omitempty"` + Tag *string `json:"tag,omitempty"` +} + +func (o *GetTopWatchedContentGenre) GetID() *int { + if o == nil { + return nil + } + return o.ID +} + +func (o *GetTopWatchedContentGenre) GetFilter() *string { + if o == nil { + return nil + } + return o.Filter +} + +func (o *GetTopWatchedContentGenre) GetTag() *string { + if o == nil { + return nil + } + return o.Tag +} + +type GetTopWatchedContentCountry struct { + ID *int `json:"id,omitempty"` + Filter *string `json:"filter,omitempty"` + Tag *string `json:"tag,omitempty"` +} + +func (o *GetTopWatchedContentCountry) GetID() *int { + if o == nil { + return nil + } + return o.ID +} + +func (o *GetTopWatchedContentCountry) GetFilter() *string { + if o == nil { + return nil + } + return o.Filter +} + +func (o *GetTopWatchedContentCountry) GetTag() *string { + if o == nil { + return nil + } + return o.Tag +} + +type GetTopWatchedContentGuids struct { + ID *string `json:"id,omitempty"` +} + +func (o *GetTopWatchedContentGuids) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +type GetTopWatchedContentRole struct { + ID *int `json:"id,omitempty"` + Filter *string `json:"filter,omitempty"` + Tag *string `json:"tag,omitempty"` + TagKey *string `json:"tagKey,omitempty"` + Role *string `json:"role,omitempty"` + Thumb *string `json:"thumb,omitempty"` +} + +func (o *GetTopWatchedContentRole) GetID() *int { + if o == nil { + return nil + } + return o.ID +} + +func (o *GetTopWatchedContentRole) GetFilter() *string { + if o == nil { + return nil + } + return o.Filter +} + +func (o *GetTopWatchedContentRole) GetTag() *string { + if o == nil { + return nil + } + return o.Tag +} + +func (o *GetTopWatchedContentRole) GetTagKey() *string { + if o == nil { + return nil + } + return o.TagKey +} + +func (o *GetTopWatchedContentRole) GetRole() *string { + if o == nil { + return nil + } + return o.Role +} + +func (o *GetTopWatchedContentRole) GetThumb() *string { + if o == nil { + return nil + } + return o.Thumb +} + +type User struct { + ID *int `json:"id,omitempty"` +} + +func (o *User) GetID() *int { + if o == nil { + return nil + } + return o.ID +} + +type GetTopWatchedContentMetadata struct { + RatingKey *string `json:"ratingKey,omitempty"` + Key *string `json:"key,omitempty"` + GUID *string `json:"guid,omitempty"` + Slug *string `json:"slug,omitempty"` + Studio *string `json:"studio,omitempty"` + Type *string `json:"type,omitempty"` + Title *string `json:"title,omitempty"` + LibrarySectionTitle *string `json:"librarySectionTitle,omitempty"` + LibrarySectionID *int `json:"librarySectionID,omitempty"` + LibrarySectionKey *string `json:"librarySectionKey,omitempty"` + ContentRating *string `json:"contentRating,omitempty"` + Summary *string `json:"summary,omitempty"` + Index *int64 `json:"index,omitempty"` + AudienceRating *float64 `json:"audienceRating,omitempty"` + Year *int `json:"year,omitempty"` + Tagline *string `json:"tagline,omitempty"` + Thumb *string `json:"thumb,omitempty"` + Art *string `json:"art,omitempty"` + Duration *int `json:"duration,omitempty"` + OriginallyAvailableAt *types.Date `json:"originallyAvailableAt,omitempty"` + LeafCount *int64 `json:"leafCount,omitempty"` + ViewedLeafCount *int64 `json:"viewedLeafCount,omitempty"` + ChildCount *int64 `json:"childCount,omitempty"` + AddedAt *int `json:"addedAt,omitempty"` + UpdatedAt *int `json:"updatedAt,omitempty"` + GlobalViewCount *int64 `json:"globalViewCount,omitempty"` + AudienceRatingImage *string `json:"audienceRatingImage,omitempty"` + Genre []GetTopWatchedContentGenre `json:"Genre,omitempty"` + Country []GetTopWatchedContentCountry `json:"Country,omitempty"` + Guids []GetTopWatchedContentGuids `json:"Guid,omitempty"` + Role []GetTopWatchedContentRole `json:"Role,omitempty"` + User []User `json:"User,omitempty"` +} + +func (g GetTopWatchedContentMetadata) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(g, "", false) +} + +func (g *GetTopWatchedContentMetadata) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &g, "", false, false); err != nil { + return err + } + return nil +} + +func (o *GetTopWatchedContentMetadata) GetRatingKey() *string { + if o == nil { + return nil + } + return o.RatingKey +} + +func (o *GetTopWatchedContentMetadata) GetKey() *string { + if o == nil { + return nil + } + return o.Key +} + +func (o *GetTopWatchedContentMetadata) GetGUID() *string { + if o == nil { + return nil + } + return o.GUID +} + +func (o *GetTopWatchedContentMetadata) GetSlug() *string { + if o == nil { + return nil + } + return o.Slug +} + +func (o *GetTopWatchedContentMetadata) GetStudio() *string { + if o == nil { + return nil + } + return o.Studio +} + +func (o *GetTopWatchedContentMetadata) GetType() *string { + if o == nil { + return nil + } + return o.Type +} + +func (o *GetTopWatchedContentMetadata) GetTitle() *string { + if o == nil { + return nil + } + return o.Title +} + +func (o *GetTopWatchedContentMetadata) GetLibrarySectionTitle() *string { + if o == nil { + return nil + } + return o.LibrarySectionTitle +} + +func (o *GetTopWatchedContentMetadata) GetLibrarySectionID() *int { + if o == nil { + return nil + } + return o.LibrarySectionID +} + +func (o *GetTopWatchedContentMetadata) GetLibrarySectionKey() *string { + if o == nil { + return nil + } + return o.LibrarySectionKey +} + +func (o *GetTopWatchedContentMetadata) GetContentRating() *string { + if o == nil { + return nil + } + return o.ContentRating +} + +func (o *GetTopWatchedContentMetadata) GetSummary() *string { + if o == nil { + return nil + } + return o.Summary +} + +func (o *GetTopWatchedContentMetadata) GetIndex() *int64 { + if o == nil { + return nil + } + return o.Index +} + +func (o *GetTopWatchedContentMetadata) GetAudienceRating() *float64 { + if o == nil { + return nil + } + return o.AudienceRating +} + +func (o *GetTopWatchedContentMetadata) GetYear() *int { + if o == nil { + return nil + } + return o.Year +} + +func (o *GetTopWatchedContentMetadata) GetTagline() *string { + if o == nil { + return nil + } + return o.Tagline +} + +func (o *GetTopWatchedContentMetadata) GetThumb() *string { + if o == nil { + return nil + } + return o.Thumb +} + +func (o *GetTopWatchedContentMetadata) GetArt() *string { + if o == nil { + return nil + } + return o.Art +} + +func (o *GetTopWatchedContentMetadata) GetDuration() *int { + if o == nil { + return nil + } + return o.Duration +} + +func (o *GetTopWatchedContentMetadata) GetOriginallyAvailableAt() *types.Date { + if o == nil { + return nil + } + return o.OriginallyAvailableAt +} + +func (o *GetTopWatchedContentMetadata) GetLeafCount() *int64 { + if o == nil { + return nil + } + return o.LeafCount +} + +func (o *GetTopWatchedContentMetadata) GetViewedLeafCount() *int64 { + if o == nil { + return nil + } + return o.ViewedLeafCount +} + +func (o *GetTopWatchedContentMetadata) GetChildCount() *int64 { + if o == nil { + return nil + } + return o.ChildCount +} + +func (o *GetTopWatchedContentMetadata) GetAddedAt() *int { + if o == nil { + return nil + } + return o.AddedAt +} + +func (o *GetTopWatchedContentMetadata) GetUpdatedAt() *int { + if o == nil { + return nil + } + return o.UpdatedAt +} + +func (o *GetTopWatchedContentMetadata) GetGlobalViewCount() *int64 { + if o == nil { + return nil + } + return o.GlobalViewCount +} + +func (o *GetTopWatchedContentMetadata) GetAudienceRatingImage() *string { + if o == nil { + return nil + } + return o.AudienceRatingImage +} + +func (o *GetTopWatchedContentMetadata) GetGenre() []GetTopWatchedContentGenre { + if o == nil { + return nil + } + return o.Genre +} + +func (o *GetTopWatchedContentMetadata) GetCountry() []GetTopWatchedContentCountry { + if o == nil { + return nil + } + return o.Country +} + +func (o *GetTopWatchedContentMetadata) GetGuids() []GetTopWatchedContentGuids { + if o == nil { + return nil + } + return o.Guids +} + +func (o *GetTopWatchedContentMetadata) GetRole() []GetTopWatchedContentRole { + if o == nil { + return nil + } + return o.Role +} + +func (o *GetTopWatchedContentMetadata) GetUser() []User { + if o == nil { + return nil + } + return o.User +} + +type GetTopWatchedContentMediaContainer struct { + Size *int `json:"size,omitempty"` + AllowSync *bool `json:"allowSync,omitempty"` + Identifier *string `json:"identifier,omitempty"` + MediaTagPrefix *string `json:"mediaTagPrefix,omitempty"` + MediaTagVersion *int `json:"mediaTagVersion,omitempty"` + Metadata []GetTopWatchedContentMetadata `json:"Metadata,omitempty"` +} + +func (o *GetTopWatchedContentMediaContainer) GetSize() *int { + if o == nil { + return nil + } + return o.Size +} + +func (o *GetTopWatchedContentMediaContainer) GetAllowSync() *bool { + if o == nil { + return nil + } + return o.AllowSync +} + +func (o *GetTopWatchedContentMediaContainer) GetIdentifier() *string { + if o == nil { + return nil + } + return o.Identifier +} + +func (o *GetTopWatchedContentMediaContainer) GetMediaTagPrefix() *string { + if o == nil { + return nil + } + return o.MediaTagPrefix +} + +func (o *GetTopWatchedContentMediaContainer) GetMediaTagVersion() *int { + if o == nil { + return nil + } + return o.MediaTagVersion +} + +func (o *GetTopWatchedContentMediaContainer) GetMetadata() []GetTopWatchedContentMetadata { + if o == nil { + return nil + } + return o.Metadata +} + +// GetTopWatchedContentResponseBody - The metadata of the library item. +type GetTopWatchedContentResponseBody struct { + MediaContainer *GetTopWatchedContentMediaContainer `json:"MediaContainer,omitempty"` +} + +func (o *GetTopWatchedContentResponseBody) GetMediaContainer() *GetTopWatchedContentMediaContainer { + if o == nil { + return nil + } + return o.MediaContainer +} + +type GetTopWatchedContentResponse 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 metadata of the library item. + Object *GetTopWatchedContentResponseBody +} + +func (o *GetTopWatchedContentResponse) GetContentType() string { + if o == nil { + return "" + } + return o.ContentType +} + +func (o *GetTopWatchedContentResponse) GetStatusCode() int { + if o == nil { + return 0 + } + return o.StatusCode +} + +func (o *GetTopWatchedContentResponse) GetRawResponse() *http.Response { + if o == nil { + return nil + } + return o.RawResponse +} + +func (o *GetTopWatchedContentResponse) GetObject() *GetTopWatchedContentResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/internal/sdk/models/operations/getwatchlist.go b/internal/sdk/models/operations/getwatchlist.go index 5d11673..fe346b8 100644 --- a/internal/sdk/models/operations/getwatchlist.go +++ b/internal/sdk/models/operations/getwatchlist.go @@ -14,19 +14,19 @@ var GetWatchlistServerList = []string{ "https://metadata.provider.plex.tv", } -// Filter -type Filter string +// PathParamFilter - Filter +type PathParamFilter string const ( - FilterAll Filter = "all" - FilterAvailable Filter = "available" - FilterReleased Filter = "released" + PathParamFilterAll PathParamFilter = "all" + PathParamFilterAvailable PathParamFilter = "available" + PathParamFilterReleased PathParamFilter = "released" ) -func (e Filter) ToPointer() *Filter { +func (e PathParamFilter) ToPointer() *PathParamFilter { return &e } -func (e *Filter) UnmarshalJSON(data []byte) error { +func (e *PathParamFilter) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { return err @@ -37,10 +37,10 @@ func (e *Filter) UnmarshalJSON(data []byte) error { case "available": fallthrough case "released": - *e = Filter(v) + *e = PathParamFilter(v) return nil default: - return fmt.Errorf("invalid value for Filter: %v", v) + return fmt.Errorf("invalid value for PathParamFilter: %v", v) } } @@ -127,7 +127,7 @@ func (e *IncludeExternalMedia) UnmarshalJSON(data []byte) error { type GetWatchlistRequest struct { // Filter - Filter Filter `pathParam:"style=simple,explode=false,name=filter"` + Filter PathParamFilter `pathParam:"style=simple,explode=false,name=filter"` // In the format "field:dir". Available fields are "watchlistedAt" (Added At), // "titleSort" (Title), "originallyAvailableAt" (Release Date), or "rating" (Critic Rating). // "dir" can be "asc" or "desc" @@ -158,9 +158,9 @@ type GetWatchlistRequest struct { XPlexContainerSize *int `queryParam:"style=form,explode=true,name=X-Plex-Container-Size"` } -func (o *GetWatchlistRequest) GetFilter() Filter { +func (o *GetWatchlistRequest) GetFilter() PathParamFilter { if o == nil { - return Filter("") + return PathParamFilter("") } return o.Filter } diff --git a/internal/sdk/playlists.go b/internal/sdk/playlists.go index 82d5841..75e8dec 100644 --- a/internal/sdk/playlists.go +++ b/internal/sdk/playlists.go @@ -419,7 +419,7 @@ func (s *Playlists) DeletePlaylist(ctx context.Context, request operations.Delet httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { - case httpRes.StatusCode == 200: + case httpRes.StatusCode == 204: fallthrough case httpRes.StatusCode == 400: case httpRes.StatusCode == 401: diff --git a/internal/sdk/plexapi.go b/internal/sdk/plexapi.go index 791354c..49fbaf8 100644 --- a/internal/sdk/plexapi.go +++ b/internal/sdk/plexapi.go @@ -163,7 +163,6 @@ func WithServerIndex(serverIndex int) SDKOption { } } -// ServerProtocol - The protocol to use when connecting to your plex server. type ServerProtocol string const ( @@ -255,7 +254,7 @@ func WithSecuritySource(security func(context.Context) (shared.Security, error)) // WithXPlexClientIdentifier allows setting the XPlexClientIdentifier parameter for all supported operations func WithXPlexClientIdentifier(xPlexClientIdentifier string) SDKOption { return func(sdk *PlexAPI) { - sdk.sdkConfiguration.Globals.XPlexClientIdentifier = xPlexClientIdentifier + sdk.sdkConfiguration.Globals.XPlexClientIdentifier = &xPlexClientIdentifier } } @@ -272,8 +271,8 @@ func New(opts ...SDKOption) *PlexAPI { Language: "go", OpenAPIDocVersion: "0.0.3", SDKVersion: "0.0.1", - GenVersion: "2.342.6", - UserAgent: "speakeasy-sdk/go 0.0.1 2.342.6 0.0.3 github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk", + GenVersion: "2.349.6", + UserAgent: "speakeasy-sdk/go 0.0.1 2.349.6 0.0.3 github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk", Globals: globals.Globals{}, ServerDefaults: []map[string]string{ { diff --git a/internal/sdk/server.go b/internal/sdk/server.go index 6bbb0e0..ea0d9d1 100644 --- a/internal/sdk/server.go +++ b/internal/sdk/server.go @@ -26,8 +26,8 @@ func newServer(sdkConfig sdkConfiguration) *Server { } } -// GetServerCapabilities - Server Capabilities -// Server Capabilities +// GetServerCapabilities - Get Server Capabilities +// Get Server Capabilities func (s *Server) GetServerCapabilities(ctx context.Context) (*operations.GetServerCapabilitiesResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, diff --git a/internal/sdk/sessions.go b/internal/sdk/sessions.go index 9aaa7a6..fec13ad 100644 --- a/internal/sdk/sessions.go +++ b/internal/sdk/sessions.go @@ -131,7 +131,7 @@ func (s *Sessions) GetSessions(ctx context.Context) (*operations.GetSessionsResp // GetSessionHistory - Get Session History // This will Retrieve a listing of all history views. -func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessionHistoryResponse, error) { +func (s *Sessions) GetSessionHistory(ctx context.Context, request operations.GetSessionHistoryRequest) (*operations.GetSessionHistoryResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "getSessionHistory", @@ -152,6 +152,10 @@ func (s *Sessions) GetSessionHistory(ctx context.Context) (*operations.GetSessio req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { return nil, err } diff --git a/internal/sdk/statistics.go b/internal/sdk/statistics.go index d1113b9..6b1ea22 100644 --- a/internal/sdk/statistics.go +++ b/internal/sdk/statistics.go @@ -132,3 +132,217 @@ func (s *Statistics) GetStatistics(ctx context.Context, request operations.GetSt return res, nil } + +// GetResourcesStatistics - Get Resources Statistics +// This will return the resources for the server +func (s *Statistics) GetResourcesStatistics(ctx context.Context, request operations.GetResourcesStatisticsRequest) (*operations.GetResourcesStatisticsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getResourcesStatistics", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/statistics/resources") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + + res := &operations.GetResourcesStatisticsResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + 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(httpRes.Header.Get("Content-Type"), `application/json`): + var out operations.GetResourcesStatisticsResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.TwoHundredApplicationJSONObject = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + case httpRes.StatusCode == 401: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out operations.GetResourcesStatisticsStatisticsResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.FourHundredAndOneApplicationJSONObject = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// GetBandwidthStatistics - Get Bandwidth Statistics +// This will return the bandwidth statistics for the server +func (s *Statistics) GetBandwidthStatistics(ctx context.Context, request operations.GetBandwidthStatisticsRequest) (*operations.GetBandwidthStatisticsResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "getBandwidthStatistics", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/statistics/bandwidth") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + + res := &operations.GetBandwidthStatisticsResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + 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(httpRes.Header.Get("Content-Type"), `application/json`): + var out operations.GetBandwidthStatisticsResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.TwoHundredApplicationJSONObject = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + case httpRes.StatusCode == 401: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out operations.GetBandwidthStatisticsStatisticsResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.FourHundredAndOneApplicationJSONObject = &out + default: + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +}