ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.193.0

This commit is contained in:
speakeasybot
2024-02-23 14:47:01 +00:00
parent 1adccc4c2f
commit a99ab4b4c2
12 changed files with 536 additions and 239 deletions

View File

@@ -1,27 +1,27 @@
lockVersion: 2.0.0
id: e742591b-391d-4f4e-8484-d01a093b32ec
management:
docChecksum: 099fc5bbb987ae7e391f7f07b4212860
docChecksum: 278d186496d83d5830ba4870f8cad39d
docVersion: 0.0.3
speakeasyVersion: internal
generationVersion: 2.249.1
releaseVersion: 0.5.0
configChecksum: 1c7e54baac47fdd8c7da2254b5ada2fd
generationVersion: 2.269.0
releaseVersion: 0.6.0
configChecksum: 8b5014a8db27030d0bae86f162af255d
repoURL: https://github.com/LukeHagar/plexterraform.git
repoSubDirectory: .
published: true
features:
terraform:
constsAndDefaults: 0.1.2
core: 3.9.4
constsAndDefaults: 0.1.3
core: 3.10.0
globalSecurity: 2.81.3
globalServerURLs: 2.82.1
methodServerURLs: 2.82.1
nameOverrides: 2.81.1
unions: 2.81.7
generatedFiles:
- internal/sdk/server.go
- internal/sdk/media.go
- internal/sdk/video.go
- internal/sdk/activities.go
- internal/sdk/butler.go
- internal/sdk/hubs.go
@@ -31,9 +31,9 @@ generatedFiles:
- internal/sdk/plex.go
- internal/sdk/playlists.go
- internal/sdk/security.go
- internal/sdk/statistics.go
- internal/sdk/sessions.go
- internal/sdk/updater.go
- internal/sdk/video.go
- internal/sdk/sdk.go
- examples/README.md
- go.mod
@@ -106,6 +106,8 @@ generatedFiles:
- internal/sdk/pkg/models/operations/markplayed.go
- internal/sdk/pkg/models/operations/markunplayed.go
- internal/sdk/pkg/models/operations/updateplayprogress.go
- internal/sdk/pkg/models/operations/gettimeline.go
- internal/sdk/pkg/models/operations/startuniversaltranscode.go
- internal/sdk/pkg/models/operations/getserveractivities.go
- internal/sdk/pkg/models/operations/cancelserveractivities.go
- internal/sdk/pkg/models/operations/getbutlertasks.go
@@ -145,6 +147,7 @@ generatedFiles:
- internal/sdk/pkg/models/operations/uploadplaylist.go
- internal/sdk/pkg/models/operations/gettransienttoken.go
- internal/sdk/pkg/models/operations/getsourceconnectioninformation.go
- internal/sdk/pkg/models/operations/getstatistics.go
- internal/sdk/pkg/models/operations/getsessions.go
- internal/sdk/pkg/models/operations/getsessionhistory.go
- internal/sdk/pkg/models/operations/gettranscodesessions.go
@@ -152,8 +155,6 @@ generatedFiles:
- internal/sdk/pkg/models/operations/getupdatestatus.go
- internal/sdk/pkg/models/operations/checkforupdates.go
- internal/sdk/pkg/models/operations/applyupdates.go
- internal/sdk/pkg/models/operations/startuniversaltranscode.go
- internal/sdk/pkg/models/operations/gettimeline.go
- internal/sdk/pkg/models/shared/security.go
- USAGE.md
- internal/provider/provider.go

View File

@@ -61,7 +61,7 @@ terraform {
required_providers {
PlexAPI = {
source = "LukeHagar/PlexAPI"
version = "0.5.0"
version = "0.6.0"
}
}
}

View File

@@ -111,3 +111,11 @@ Based on:
- Speakeasy CLI 1.166.1 (2.249.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [terraform v0.5.0] .
## 2024-02-23 14:46:27
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.193.0 (2.269.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [terraform v0.6.0] .

View File

@@ -17,7 +17,7 @@ terraform {
required_providers {
PlexAPI = {
source = "LukeHagar/PlexAPI"
version = "0.5.0"
version = "0.6.0"
}
}
}

View File

@@ -2,7 +2,7 @@ terraform {
required_providers {
PlexAPI = {
source = "LukeHagar/PlexAPI"
version = "0.5.0"
version = "0.6.0"
}
}
}

View File

@@ -8,8 +8,9 @@ generation:
fixes:
nameResolutionDec2023: false
parameterOrderingFeb2024: false
requestResponseComponentNamesFeb2024: false
terraform:
version: 0.5.0
version: 0.6.0
author: LukeHagar
imports:
option: openapi

View File

@@ -3,8 +3,6 @@
package operations
import (
"errors"
"github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk/pkg/utils"
"net/http"
)
@@ -47,227 +45,89 @@ func (o *GetServerPreferencesServerResponseBody) GetErrors() []GetServerPreferen
return o.Errors
}
type Two struct {
type Setting struct {
ID *string `json:"id,omitempty"`
Label *string `json:"label,omitempty"`
Summary *string `json:"summary,omitempty"`
Type *string `json:"type,omitempty"`
Default *int `json:"default,omitempty"`
Value *int `json:"value,omitempty"`
Default *bool `json:"default,omitempty"`
Value *bool `json:"value,omitempty"`
Hidden *bool `json:"hidden,omitempty"`
Advanced *bool `json:"advanced,omitempty"`
Group *string `json:"group,omitempty"`
EnumValues *string `json:"enumValues,omitempty"`
}
func (o *Two) GetID() *string {
func (o *Setting) GetID() *string {
if o == nil {
return nil
}
return o.ID
}
func (o *Two) GetLabel() *string {
func (o *Setting) GetLabel() *string {
if o == nil {
return nil
}
return o.Label
}
func (o *Two) GetSummary() *string {
func (o *Setting) GetSummary() *string {
if o == nil {
return nil
}
return o.Summary
}
func (o *Two) GetType() *string {
func (o *Setting) GetType() *string {
if o == nil {
return nil
}
return o.Type
}
func (o *Two) GetDefault() *int {
func (o *Setting) GetDefault() *bool {
if o == nil {
return nil
}
return o.Default
}
func (o *Two) GetValue() *int {
func (o *Setting) GetValue() *bool {
if o == nil {
return nil
}
return o.Value
}
func (o *Two) GetHidden() *bool {
func (o *Setting) GetHidden() *bool {
if o == nil {
return nil
}
return o.Hidden
}
func (o *Two) GetAdvanced() *bool {
func (o *Setting) GetAdvanced() *bool {
if o == nil {
return nil
}
return o.Advanced
}
func (o *Two) GetGroup() *string {
func (o *Setting) GetGroup() *string {
if o == nil {
return nil
}
return o.Group
}
func (o *Two) GetEnumValues() *string {
func (o *Setting) GetEnumValues() *string {
if o == nil {
return nil
}
return o.EnumValues
}
type One struct {
ID *string `json:"id,omitempty"`
Label *string `json:"label,omitempty"`
Summary *string `json:"summary,omitempty"`
Type *string `json:"type,omitempty"`
Default *string `json:"default,omitempty"`
Value *string `json:"value,omitempty"`
Hidden *bool `json:"hidden,omitempty"`
Advanced *bool `json:"advanced,omitempty"`
Group *string `json:"group,omitempty"`
}
func (o *One) GetID() *string {
if o == nil {
return nil
}
return o.ID
}
func (o *One) GetLabel() *string {
if o == nil {
return nil
}
return o.Label
}
func (o *One) GetSummary() *string {
if o == nil {
return nil
}
return o.Summary
}
func (o *One) GetType() *string {
if o == nil {
return nil
}
return o.Type
}
func (o *One) GetDefault() *string {
if o == nil {
return nil
}
return o.Default
}
func (o *One) GetValue() *string {
if o == nil {
return nil
}
return o.Value
}
func (o *One) GetHidden() *bool {
if o == nil {
return nil
}
return o.Hidden
}
func (o *One) GetAdvanced() *bool {
if o == nil {
return nil
}
return o.Advanced
}
func (o *One) GetGroup() *string {
if o == nil {
return nil
}
return o.Group
}
type SettingType string
const (
SettingTypeOne SettingType = "1"
SettingTypeTwo SettingType = "2"
)
type Setting struct {
One *One
Two *Two
Type SettingType
}
func CreateSettingOne(one One) Setting {
typ := SettingTypeOne
return Setting{
One: &one,
Type: typ,
}
}
func CreateSettingTwo(two Two) Setting {
typ := SettingTypeTwo
return Setting{
Two: &two,
Type: typ,
}
}
func (u *Setting) UnmarshalJSON(data []byte) error {
one := new(One)
if err := utils.UnmarshalJSON(data, &one, "", true, true); err == nil {
u.One = one
u.Type = SettingTypeOne
return nil
}
two := new(Two)
if err := utils.UnmarshalJSON(data, &two, "", true, true); err == nil {
u.Two = two
u.Type = SettingTypeTwo
return nil
}
return errors.New("could not unmarshal into supported union types")
}
func (u Setting) MarshalJSON() ([]byte, error) {
if u.One != nil {
return utils.MarshalJSON(u.One, "", true)
}
if u.Two != nil {
return utils.MarshalJSON(u.Two, "", true)
}
return nil, errors.New("could not marshal union type: all fields are null")
}
type GetServerPreferencesMediaContainer struct {
Size *int `json:"size,omitempty"`
Setting []Setting `json:"Setting,omitempty"`

View File

@@ -0,0 +1,324 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package operations
import (
"net/http"
)
type GetStatisticsRequest 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 *GetStatisticsRequest) GetTimespan() *int64 {
if o == nil {
return nil
}
return o.Timespan
}
type GetStatisticsErrors struct {
Code *float64 `json:"code,omitempty"`
Message *string `json:"message,omitempty"`
Status *float64 `json:"status,omitempty"`
}
func (o *GetStatisticsErrors) GetCode() *float64 {
if o == nil {
return nil
}
return o.Code
}
func (o *GetStatisticsErrors) GetMessage() *string {
if o == nil {
return nil
}
return o.Message
}
func (o *GetStatisticsErrors) GetStatus() *float64 {
if o == nil {
return nil
}
return o.Status
}
// GetStatisticsStatisticsResponseBody - Unauthorized - Returned if the X-Plex-Token is missing from the header or query.
type GetStatisticsStatisticsResponseBody struct {
Errors []GetStatisticsErrors `json:"errors,omitempty"`
}
func (o *GetStatisticsStatisticsResponseBody) GetErrors() []GetStatisticsErrors {
if o == nil {
return nil
}
return o.Errors
}
type GetStatisticsDevice 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 *GetStatisticsDevice) GetID() *int {
if o == nil {
return nil
}
return o.ID
}
func (o *GetStatisticsDevice) GetName() *string {
if o == nil {
return nil
}
return o.Name
}
func (o *GetStatisticsDevice) GetPlatform() *string {
if o == nil {
return nil
}
return o.Platform
}
func (o *GetStatisticsDevice) GetClientIdentifier() *string {
if o == nil {
return nil
}
return o.ClientIdentifier
}
func (o *GetStatisticsDevice) GetCreatedAt() *int {
if o == nil {
return nil
}
return o.CreatedAt
}
type Account 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 *Account) GetID() *int {
if o == nil {
return nil
}
return o.ID
}
func (o *Account) GetKey() *string {
if o == nil {
return nil
}
return o.Key
}
func (o *Account) GetName() *string {
if o == nil {
return nil
}
return o.Name
}
func (o *Account) GetDefaultAudioLanguage() *string {
if o == nil {
return nil
}
return o.DefaultAudioLanguage
}
func (o *Account) GetAutoSelectAudio() *bool {
if o == nil {
return nil
}
return o.AutoSelectAudio
}
func (o *Account) GetDefaultSubtitleLanguage() *string {
if o == nil {
return nil
}
return o.DefaultSubtitleLanguage
}
func (o *Account) GetSubtitleMode() *int {
if o == nil {
return nil
}
return o.SubtitleMode
}
func (o *Account) GetThumb() *string {
if o == nil {
return nil
}
return o.Thumb
}
type StatisticsMedia struct {
AccountID *int `json:"accountID,omitempty"`
DeviceID *int `json:"deviceID,omitempty"`
Timespan *int `json:"timespan,omitempty"`
At *int `json:"at,omitempty"`
MetadataType *int `json:"metadataType,omitempty"`
Count *int `json:"count,omitempty"`
Duration *int `json:"duration,omitempty"`
}
func (o *StatisticsMedia) GetAccountID() *int {
if o == nil {
return nil
}
return o.AccountID
}
func (o *StatisticsMedia) GetDeviceID() *int {
if o == nil {
return nil
}
return o.DeviceID
}
func (o *StatisticsMedia) GetTimespan() *int {
if o == nil {
return nil
}
return o.Timespan
}
func (o *StatisticsMedia) GetAt() *int {
if o == nil {
return nil
}
return o.At
}
func (o *StatisticsMedia) GetMetadataType() *int {
if o == nil {
return nil
}
return o.MetadataType
}
func (o *StatisticsMedia) GetCount() *int {
if o == nil {
return nil
}
return o.Count
}
func (o *StatisticsMedia) GetDuration() *int {
if o == nil {
return nil
}
return o.Duration
}
type GetStatisticsMediaContainer struct {
Size *int `json:"size,omitempty"`
Device []GetStatisticsDevice `json:"Device,omitempty"`
Account []Account `json:"Account,omitempty"`
StatisticsMedia []StatisticsMedia `json:"StatisticsMedia,omitempty"`
}
func (o *GetStatisticsMediaContainer) GetSize() *int {
if o == nil {
return nil
}
return o.Size
}
func (o *GetStatisticsMediaContainer) GetDevice() []GetStatisticsDevice {
if o == nil {
return nil
}
return o.Device
}
func (o *GetStatisticsMediaContainer) GetAccount() []Account {
if o == nil {
return nil
}
return o.Account
}
func (o *GetStatisticsMediaContainer) GetStatisticsMedia() []StatisticsMedia {
if o == nil {
return nil
}
return o.StatisticsMedia
}
// GetStatisticsResponseBody - Media Statistics
type GetStatisticsResponseBody struct {
MediaContainer *GetStatisticsMediaContainer `json:"MediaContainer,omitempty"`
}
func (o *GetStatisticsResponseBody) GetMediaContainer() *GetStatisticsMediaContainer {
if o == nil {
return nil
}
return o.MediaContainer
}
type GetStatisticsResponse 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
// Media Statistics
TwoHundredApplicationJSONObject *GetStatisticsResponseBody
// Unauthorized - Returned if the X-Plex-Token is missing from the header or query.
FourHundredAndOneApplicationJSONObject *GetStatisticsStatisticsResponseBody
}
func (o *GetStatisticsResponse) GetContentType() string {
if o == nil {
return ""
}
return o.ContentType
}
func (o *GetStatisticsResponse) GetStatusCode() int {
if o == nil {
return 0
}
return o.StatusCode
}
func (o *GetStatisticsResponse) GetRawResponse() *http.Response {
if o == nil {
return nil
}
return o.RawResponse
}
func (o *GetStatisticsResponse) GetTwoHundredApplicationJSONObject() *GetStatisticsResponseBody {
if o == nil {
return nil
}
return o.TwoHundredApplicationJSONObject
}
func (o *GetStatisticsResponse) GetFourHundredAndOneApplicationJSONObject() *GetStatisticsStatisticsResponseBody {
if o == nil {
return nil
}
return o.FourHundredAndOneApplicationJSONObject
}

View File

@@ -358,7 +358,7 @@ func handleDefaultConstValue(tagValue string, val interface{}, tag reflect.Struc
return []byte(fmt.Sprintf(`"%s"`, tagValue))
default:
if typ.Kind() == reflect.String {
return []byte(fmt.Sprintf(`"%s"`, tagValue))
return []byte(fmt.Sprintf("%q", tagValue))
}
}

View File

@@ -73,6 +73,9 @@ type PlexAPI struct {
// API Calls interacting with Plex Media Server Media
//
Media *Media
// API Calls that perform operations with Plex Media Server Videos
//
Video *Video
// Activities are awesome. They provide a way to monitor and control asynchronous operations on the server. In order to receive real-time updates for activities, a client would normally subscribe via either EventSource or Websocket endpoints.
// Activities are associated with HTTP replies via a special `X-Plex-Activity` header which contains the UUID of the activity.
// Activities are optional cancellable. If cancellable, they may be cancelled via the `DELETE` endpoint. Other details:
@@ -109,6 +112,9 @@ type PlexAPI struct {
// API Calls against Security for Plex Media Server
//
Security *Security
// API Calls that perform operations with Plex Media Server Statistics
//
Statistics *Statistics
// API Calls that perform search operations with Plex Media Server Sessions
//
Sessions *Sessions
@@ -116,9 +122,6 @@ type PlexAPI struct {
// Updates to the status can be observed via the Event API.
//
Updater *Updater
// API Calls that perform operations with Plex Media Server Videos
//
Video *Video
sdkConfiguration sdkConfiguration
}
@@ -262,9 +265,9 @@ func New(opts ...SDKOption) *PlexAPI {
sdkConfiguration: sdkConfiguration{
Language: "go",
OpenAPIDocVersion: "0.0.3",
SDKVersion: "0.5.0",
GenVersion: "2.249.1",
UserAgent: "speakeasy-sdk/go 0.5.0 2.249.1 0.0.3 PlexAPI",
SDKVersion: "0.6.0",
GenVersion: "2.269.0",
UserAgent: "speakeasy-sdk/go 0.6.0 2.269.0 0.0.3 PlexAPI",
ServerDefaults: []map[string]string{
{
"protocol": "http",
@@ -294,6 +297,8 @@ func New(opts ...SDKOption) *PlexAPI {
sdk.Media = newMedia(sdk.sdkConfiguration)
sdk.Video = newVideo(sdk.sdkConfiguration)
sdk.Activities = newActivities(sdk.sdkConfiguration)
sdk.Butler = newButler(sdk.sdkConfiguration)
@@ -312,11 +317,11 @@ func New(opts ...SDKOption) *PlexAPI {
sdk.Security = newSecurity(sdk.sdkConfiguration)
sdk.Statistics = newStatistics(sdk.sdkConfiguration)
sdk.Sessions = newSessions(sdk.sdkConfiguration)
sdk.Updater = newUpdater(sdk.sdkConfiguration)
sdk.Video = newVideo(sdk.sdkConfiguration)
return sdk
}

View File

@@ -0,0 +1,98 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package sdk
import (
"bytes"
"context"
"fmt"
"github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk/pkg/models/operations"
"github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk/pkg/models/sdkerrors"
"github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk/pkg/utils"
"io"
"net/http"
"strings"
)
// Statistics - API Calls that perform operations with Plex Media Server Statistics
type Statistics struct {
sdkConfiguration sdkConfiguration
}
func newStatistics(sdkConfig sdkConfiguration) *Statistics {
return &Statistics{
sdkConfiguration: sdkConfig,
}
}
// GetStatistics - Get Media Statistics
// This will return the media statistics for the server
func (s *Statistics) GetStatistics(ctx context.Context, request operations.GetStatisticsRequest) (*operations.GetStatisticsResponse, error) {
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
url := strings.TrimSuffix(baseURL, "/") + "/statistics/media"
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)
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")
}
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))
contentType := httpRes.Header.Get("Content-Type")
res := &operations.GetStatisticsResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
RawResponse: httpRes,
}
switch {
case httpRes.StatusCode == 200:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out operations.GetStatisticsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
res.TwoHundredApplicationJSONObject = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
case httpRes.StatusCode == 400:
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out operations.GetStatisticsStatisticsResponseBody
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil {
return nil, err
}
res.FourHundredAndOneApplicationJSONObject = &out
default:
return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", contentType), httpRes.StatusCode, string(rawBody), httpRes)
}
}
return res, nil
}

View File

@@ -25,68 +25,6 @@ func newVideo(sdkConfig sdkConfiguration) *Video {
}
}
// StartUniversalTranscode - Start Universal Transcode
// Begin a Universal Transcode Session
func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.StartUniversalTranscodeRequest) (*operations.StartUniversalTranscodeResponse, error) {
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
url := strings.TrimSuffix(baseURL, "/") + "/video/:/transcode/universal/start.mpd"
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)
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")
}
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))
contentType := httpRes.Header.Get("Content-Type")
res := &operations.StartUniversalTranscodeResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
RawResponse: httpRes,
}
switch {
case httpRes.StatusCode == 200:
fallthrough
case httpRes.StatusCode == 400:
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out operations.StartUniversalTranscodeResponseBody
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)
}
}
return res, nil
}
// GetTimeline - Get the timeline for a media item
// Get the timeline for a media item
func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineRequest) (*operations.GetTimelineResponse, error) {
@@ -148,3 +86,65 @@ func (s *Video) GetTimeline(ctx context.Context, request operations.GetTimelineR
return res, nil
}
// StartUniversalTranscode - Start Universal Transcode
// Begin a Universal Transcode Session
func (s *Video) StartUniversalTranscode(ctx context.Context, request operations.StartUniversalTranscodeRequest) (*operations.StartUniversalTranscodeResponse, error) {
baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails())
url := strings.TrimSuffix(baseURL, "/") + "/video/:/transcode/universal/start.mpd"
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)
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")
}
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))
contentType := httpRes.Header.Get("Content-Type")
res := &operations.StartUniversalTranscodeResponse{
StatusCode: httpRes.StatusCode,
ContentType: contentType,
RawResponse: httpRes,
}
switch {
case httpRes.StatusCode == 200:
fallthrough
case httpRes.StatusCode == 400:
case httpRes.StatusCode == 401:
switch {
case utils.MatchContentType(contentType, `application/json`):
var out operations.StartUniversalTranscodeResponseBody
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)
}
}
return res, nil
}