Skip to content

Commit

Permalink
Delivery Usage, Simulcasting, Audio Normalization, and a variety of b…
Browse files Browse the repository at this point in the history
…ugfixes. (muxinc#9)

* Delivery Usage, Simulcasting, and Audio Normalization

* Test Simulcast

* Test Delivery Usage

* Test normalize audio

* Reinstate delete asset step

* Support master access on asset creation

* Pull in latest fixes for reduced latency

* Typo
  • Loading branch information
philcluff authored Dec 6, 2019
1 parent 0e6e71c commit 50be5ac
Show file tree
Hide file tree
Showing 29 changed files with 716 additions and 18 deletions.
115 changes: 115 additions & 0 deletions api_delivery_usage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Mux Go - Copyright 2019 Mux Inc.
// NOTE: This file is auto generated. Do not edit this file manually.

package muxgo

import (
"io/ioutil"
"net/url"
"strings"
)

type DeliveryUsageApiService service

type ListDeliveryUsageParams struct {
Page int32
Limit int32
AssetId string
Timeframe []string
}

// ListDeliveryUsage optionally accepts the APIOption of WithParams(*ListDeliveryUsageParams).
func (a *DeliveryUsageApiService) ListDeliveryUsage(opts ...APIOption) (ListDeliveryUsageResponse, error) {
var (
localVarAPIOptions = new(APIOptions)
localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue ListDeliveryUsageResponse
)

for _, opt := range opts {
opt(localVarAPIOptions)
}

localVarOptionals, ok := localVarAPIOptions.params.(*ListDeliveryUsageParams)
if localVarAPIOptions.params != nil && !ok {
return localVarReturnValue, reportError("provided params were not of type *ListDeliveryUsageParams")
}

// create path and map variables
localVarPath := a.client.cfg.basePath + "/video/v1/delivery-usage"

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

if localVarOptionals != nil && isSet(localVarOptionals.Page) {
localVarQueryParams.Add("page", parameterToString(localVarOptionals.Page, ""))
}
if localVarOptionals != nil && isSet(localVarOptionals.Limit) {
localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit, ""))
}
if localVarOptionals != nil && isSet(localVarOptionals.AssetId) {
localVarQueryParams.Add("asset_id", parameterToString(localVarOptionals.AssetId, ""))
}
if localVarOptionals != nil && isSet(localVarOptionals.Timeframe) {
// This will "always work" for Mux's use case, since we always treat collections in query params as "multi" types.
// The first version of this code checked the collectionFormat, but that's just wasted CPU cycles right now.
for _, v := range localVarOptionals.Timeframe {
localVarQueryParams.Add("timeframe[]", v)
}
}
// to determine the Content-Type header
localVarHttpContentTypes := []string{}

// set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}

// to determine the Accept header
localVarHttpHeaderAccepts := []string{"application/json"}

// set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}

r, err := a.client.prepareRequest(localVarAPIOptions, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, err
}

localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return localVarReturnValue, err
}

localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return localVarReturnValue, err
}

// Check for common HTTP error status codes
err = CheckForHttpError(localVarHttpResponse.StatusCode, localVarBody)
if err != nil {
return localVarReturnValue, err
}

err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, newErr
}

return localVarReturnValue, nil
}
219 changes: 219 additions & 0 deletions api_live_streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,83 @@ func (a *LiveStreamsApiService) CreateLiveStreamPlaybackId(lIVESTREAMID string,
return localVarReturnValue, nil
}

func (a *LiveStreamsApiService) CreateLiveStreamSimulcastTarget(lIVESTREAMID string, createSimulcastTargetRequest CreateSimulcastTargetRequest, opts ...APIOption) (SimulcastTargetResponse, error) {
var (
localVarAPIOptions = new(APIOptions)
localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue SimulcastTargetResponse
)

for _, opt := range opts {
opt(localVarAPIOptions)
}

// create path and map variables
localVarPath := a.client.cfg.basePath + "/video/v1/live-streams/{LIVE_STREAM_ID}/simulcast-targets"
localVarPath = strings.Replace(localVarPath, "{"+"LIVE_STREAM_ID"+"}", fmt.Sprintf("%v", lIVESTREAMID), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

// to determine the Content-Type header
localVarHttpContentTypes := []string{"application/json"}

// set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}

// to determine the Accept header
localVarHttpHeaderAccepts := []string{"application/json"}

// set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
// body params
localVarPostBody = &createSimulcastTargetRequest

r, err := a.client.prepareRequest(localVarAPIOptions, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, err
}

localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return localVarReturnValue, err
}

localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return localVarReturnValue, err
}

// Check for common HTTP error status codes
err = CheckForHttpError(localVarHttpResponse.StatusCode, localVarBody)
if err != nil {
return localVarReturnValue, err
}

err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, newErr
}

return localVarReturnValue, nil
}

func (a *LiveStreamsApiService) DeleteLiveStream(lIVESTREAMID string, opts ...APIOption) error {
var (
localVarAPIOptions = new(APIOptions)
Expand Down Expand Up @@ -296,6 +373,72 @@ func (a *LiveStreamsApiService) DeleteLiveStreamPlaybackId(lIVESTREAMID string,
return nil
}

func (a *LiveStreamsApiService) DeleteLiveStreamSimulcastTarget(lIVESTREAMID string, sIMULCASTTARGETID string, opts ...APIOption) error {
var (
localVarAPIOptions = new(APIOptions)
localVarHttpMethod = strings.ToUpper("Delete")
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
)

for _, opt := range opts {
opt(localVarAPIOptions)
}

// create path and map variables
localVarPath := a.client.cfg.basePath + "/video/v1/live-streams/{LIVE_STREAM_ID}/simulcast-targets/{SIMULCAST_TARGET_ID}"
localVarPath = strings.Replace(localVarPath, "{"+"LIVE_STREAM_ID"+"}", fmt.Sprintf("%v", lIVESTREAMID), -1)
localVarPath = strings.Replace(localVarPath, "{"+"SIMULCAST_TARGET_ID"+"}", fmt.Sprintf("%v", sIMULCASTTARGETID), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

// to determine the Content-Type header
localVarHttpContentTypes := []string{}

// set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}

// to determine the Accept header
localVarHttpHeaderAccepts := []string{}

// set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}

r, err := a.client.prepareRequest(localVarAPIOptions, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return err
}

localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return err
}

localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return err
}

// Check for common HTTP error status codes
err = CheckForHttpError(localVarHttpResponse.StatusCode, localVarBody)
if err != nil {
return err
}

return nil
}

func (a *LiveStreamsApiService) GetLiveStream(lIVESTREAMID string, opts ...APIOption) (LiveStreamResponse, error) {
var (
localVarAPIOptions = new(APIOptions)
Expand Down Expand Up @@ -371,6 +514,82 @@ func (a *LiveStreamsApiService) GetLiveStream(lIVESTREAMID string, opts ...APIOp
return localVarReturnValue, nil
}

func (a *LiveStreamsApiService) GetLiveStreamSimulcastTarget(lIVESTREAMID string, sIMULCASTTARGETID string, opts ...APIOption) (SimulcastTargetResponse, error) {
var (
localVarAPIOptions = new(APIOptions)
localVarHttpMethod = strings.ToUpper("Get")
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue SimulcastTargetResponse
)

for _, opt := range opts {
opt(localVarAPIOptions)
}

// create path and map variables
localVarPath := a.client.cfg.basePath + "/video/v1/live-streams/{LIVE_STREAM_ID}/simulcast-targets/{SIMULCAST_TARGET_ID}"
localVarPath = strings.Replace(localVarPath, "{"+"LIVE_STREAM_ID"+"}", fmt.Sprintf("%v", lIVESTREAMID), -1)
localVarPath = strings.Replace(localVarPath, "{"+"SIMULCAST_TARGET_ID"+"}", fmt.Sprintf("%v", sIMULCASTTARGETID), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

// to determine the Content-Type header
localVarHttpContentTypes := []string{}

// set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}

// to determine the Accept header
localVarHttpHeaderAccepts := []string{"application/json"}

// set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}

r, err := a.client.prepareRequest(localVarAPIOptions, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, err
}

localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return localVarReturnValue, err
}

localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return localVarReturnValue, err
}

// Check for common HTTP error status codes
err = CheckForHttpError(localVarHttpResponse.StatusCode, localVarBody)
if err != nil {
return localVarReturnValue, err
}

err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, newErr
}

return localVarReturnValue, nil
}

type ListLiveStreamsParams struct {
Limit int32
Page int32
Expand Down
2 changes: 2 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type APIClient struct {

// API Services
AssetsApi *AssetsApiService
DeliveryUsageApi *DeliveryUsageApiService
DirectUploadsApi *DirectUploadsApiService
ErrorsApi *ErrorsApiService
ExportsApi *ExportsApiService
Expand All @@ -63,6 +64,7 @@ func NewAPIClient(cfg *Configuration) *APIClient {

// API Services
c.AssetsApi = (*AssetsApiService)(&c.common)
c.DeliveryUsageApi = (*DeliveryUsageApiService)(&c.common)
c.DirectUploadsApi = (*DirectUploadsApiService)(&c.common)
c.ErrorsApi = (*ErrorsApiService)(&c.common)
c.ExportsApi = (*ExportsApiService)(&c.common)
Expand Down
2 changes: 1 addition & 1 deletion configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type ConfigurationOption func(*Configuration)
func NewConfiguration(opts ...ConfigurationOption) *Configuration {
cfg := &Configuration{
basePath: "https://api.mux.com",
userAgent: "Mux Go | 0.3.0",
userAgent: "Mux Go | 0.4.0",
}
for _, opt := range opts {
opt(cfg)
Expand Down
1 change: 1 addition & 0 deletions docs/Asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Name | Type | Description | Notes
**Master** | [**AssetMaster**](Asset_master.md) | | [optional]
**MasterAccess** | **string** | | [optional] [default to MASTER_ACCESS_NONE]
**Mp4Support** | **string** | | [optional] [default to MP4_SUPPORT_NONE]
**NormalizeAudio** | **bool** | | [optional] [default to false]
**StaticRenditions** | [**AssetStaticRenditions**](Asset_static_renditions.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
2 changes: 2 additions & 0 deletions docs/CreateAssetRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Name | Type | Description | Notes
**PerTitleEncode** | **bool** | | [optional]
**Passthrough** | **string** | | [optional]
**Mp4Support** | **string** | | [optional]
**NormalizeAudio** | **bool** | Normalize the audio track loudness level. This parameter is only applicable to on-demand (not live) assets. | [optional] [default to false]
**MasterAccess** | **string** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
Loading

0 comments on commit 50be5ac

Please sign in to comment.