diff --git a/api_delivery_usage.go b/api_delivery_usage.go new file mode 100644 index 0000000..cdf2cf3 --- /dev/null +++ b/api_delivery_usage.go @@ -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 +} diff --git a/api_live_streams.go b/api_live_streams.go index 5ac735b..bdf166d 100644 --- a/api_live_streams.go +++ b/api_live_streams.go @@ -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) @@ -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) @@ -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 diff --git a/client.go b/client.go index 1e002c4..2a9073e 100644 --- a/client.go +++ b/client.go @@ -38,6 +38,7 @@ type APIClient struct { // API Services AssetsApi *AssetsApiService + DeliveryUsageApi *DeliveryUsageApiService DirectUploadsApi *DirectUploadsApiService ErrorsApi *ErrorsApiService ExportsApi *ExportsApiService @@ -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) diff --git a/configuration.go b/configuration.go index cf94a27..4042869 100644 --- a/configuration.go +++ b/configuration.go @@ -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) diff --git a/docs/Asset.md b/docs/Asset.md index c6cba9b..eb932eb 100644 --- a/docs/Asset.md +++ b/docs/Asset.md @@ -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) diff --git a/docs/CreateAssetRequest.md b/docs/CreateAssetRequest.md index 7b676ed..ff91b04 100644 --- a/docs/CreateAssetRequest.md +++ b/docs/CreateAssetRequest.md @@ -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) diff --git a/docs/CreateLiveStreamRequest.md b/docs/CreateLiveStreamRequest.md index 0564532..db31da9 100644 --- a/docs/CreateLiveStreamRequest.md +++ b/docs/CreateLiveStreamRequest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **PlaybackPolicy** | [**[]PlaybackPolicy**](PlaybackPolicy.md) | | [optional] **NewAssetSettings** | [**CreateAssetRequest**](CreateAssetRequest.md) | | [optional] -**ReconnectWindow** | **float32** | When live streaming software disconnects from Mux, either intentionally or due to a drop in the network, the Reconnect Window is the time in seconds that Mux should wait for the streaming software to reconnect before considering the live stream finished and completing the recorded asset. Default: 60 seconds | [optional] [default to 60] +**ReconnectWindow** | **float32** | When live streaming software disconnects from Mux, either intentionally or due to a drop in the network, the Reconnect Window is the time in seconds that Mux should wait for the streaming software to reconnect before considering the live stream finished and completing the recorded asset. Defaults to 60 seconds on the API if not specified. | [optional] **Passthrough** | **string** | | [optional] **ReducedLatency** | **bool** | Latency is the time from when the streamer does something in real life to when you see it happen in the player. Set this if you want lower latency for your live stream. Note: Reconnect windows are incompatible with Reduced Latency and will always be set to zero (0) seconds. Read more here: https://mux.com/blog/reduced-latency-for-mux-live-streaming-now-available/ | [optional] diff --git a/docs/CreateSimulcastTargetRequest.md b/docs/CreateSimulcastTargetRequest.md new file mode 100644 index 0000000..a792928 --- /dev/null +++ b/docs/CreateSimulcastTargetRequest.md @@ -0,0 +1,12 @@ +# CreateSimulcastTargetRequest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Passthrough** | **string** | Arbitrary metadata set by you when creating a simulcast target. | [optional] +**StreamKey** | **string** | Stream Key represents a stream identifier on the third party live streaming service to send the parent live stream to. | [optional] +**Url** | **string** | RTMP hostname including application name for the third party live streaming service. Example: 'rtmp://live.example.com/app'. | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/DeliveryReport.md b/docs/DeliveryReport.md new file mode 100644 index 0000000..186efd5 --- /dev/null +++ b/docs/DeliveryReport.md @@ -0,0 +1,16 @@ +# DeliveryReport + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**LiveStreamId** | **string** | | [optional] +**AssetId** | **string** | | [optional] +**Passthrough** | **string** | | [optional] +**CreatedAt** | **string** | | [optional] +**AssetState** | **string** | | [optional] +**AssetDuration** | **float64** | | [optional] +**DeliveredSeconds** | **float64** | | [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) + + diff --git a/docs/DeliveryUsageApi.md b/docs/DeliveryUsageApi.md new file mode 100644 index 0000000..e1ca25e --- /dev/null +++ b/docs/DeliveryUsageApi.md @@ -0,0 +1,47 @@ +# \DeliveryUsageApi + +All URIs are relative to *https://api.mux.com* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**ListDeliveryUsage**](DeliveryUsageApi.md#ListDeliveryUsage) | **Get** /video/v1/delivery-usage | List Usage + + +# **ListDeliveryUsage** +> ListDeliveryUsageResponse ListDeliveryUsage(ctx, optional) +List Usage + +Returns a list of delivery usage records and their associated Asset IDs or Live Stream IDs. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***ListDeliveryUsageOpts** | optional parameters | nil if no parameters + +### Optional Parameters +Optional parameters are passed through a pointer to a ListDeliveryUsageOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **page** | **optional.Int32**| Offset by this many pages, of the size of `limit` | [default to 1] + **limit** | **optional.Int32**| Number of items to include in the response | [default to 100] + **assetId** | **optional.String**| Filter response to return delivery usage for this asset only. | + **timeframe** | [**optional.Interface of []string**](string.md)| Time window to get delivery usage information. timeframe[0] indicates the start time, timeframe[1] indicates the end time in seconds since the Unix epoch. Default time window is 1 hour representing usage from 13th to 12th hour from when the request is made. | + +### Return type + +[**ListDeliveryUsageResponse**](ListDeliveryUsageResponse.md) + +### Authorization + +[accessToken](../README.md#accessToken) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/docs/ListDeliveryUsageResponse.md b/docs/ListDeliveryUsageResponse.md new file mode 100644 index 0000000..6a5f690 --- /dev/null +++ b/docs/ListDeliveryUsageResponse.md @@ -0,0 +1,13 @@ +# ListDeliveryUsageResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Data** | [**[]DeliveryReport**](DeliveryReport.md) | | [optional] +**TotalRowCount** | **int64** | | [optional] +**Timeframe** | **[]int64** | | [optional] +**Limit** | **int64** | Number of assets returned in this response. Default value is 100. | [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) + + diff --git a/docs/LiveStream.md b/docs/LiveStream.md index 15244dc..4bb5cd9 100644 --- a/docs/LiveStream.md +++ b/docs/LiveStream.md @@ -12,8 +12,9 @@ Name | Type | Description | Notes **PlaybackIds** | [**[]PlaybackId**](PlaybackID.md) | | [optional] **NewAssetSettings** | [**Asset**](Asset.md) | | [optional] **Passthrough** | **string** | | [optional] -**ReconnectWindow** | **float64** | | [optional] +**ReconnectWindow** | **float32** | | [optional] **ReducedLatency** | **bool** | | [optional] +**SimulcastTargets** | [**[]SimulcastTarget**](SimulcastTarget.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) diff --git a/docs/LiveStreamsApi.md b/docs/LiveStreamsApi.md index 38508b6..12e5d1f 100644 --- a/docs/LiveStreamsApi.md +++ b/docs/LiveStreamsApi.md @@ -6,9 +6,12 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**CreateLiveStream**](LiveStreamsApi.md#CreateLiveStream) | **Post** /video/v1/live-streams | Create a live stream [**CreateLiveStreamPlaybackId**](LiveStreamsApi.md#CreateLiveStreamPlaybackId) | **Post** /video/v1/live-streams/{LIVE_STREAM_ID}/playback-ids | Create a live stream playback ID +[**CreateLiveStreamSimulcastTarget**](LiveStreamsApi.md#CreateLiveStreamSimulcastTarget) | **Post** /video/v1/live-streams/{LIVE_STREAM_ID}/simulcast-targets | Create a live stream simulcast target [**DeleteLiveStream**](LiveStreamsApi.md#DeleteLiveStream) | **Delete** /video/v1/live-streams/{LIVE_STREAM_ID} | Delete a live stream [**DeleteLiveStreamPlaybackId**](LiveStreamsApi.md#DeleteLiveStreamPlaybackId) | **Delete** /video/v1/live-streams/{LIVE_STREAM_ID}/playback-ids/{PLAYBACK_ID} | Delete a live stream playback ID +[**DeleteLiveStreamSimulcastTarget**](LiveStreamsApi.md#DeleteLiveStreamSimulcastTarget) | **Delete** /video/v1/live-streams/{LIVE_STREAM_ID}/simulcast-targets/{SIMULCAST_TARGET_ID} | Delete a Live Stream Simulcast Target [**GetLiveStream**](LiveStreamsApi.md#GetLiveStream) | **Get** /video/v1/live-streams/{LIVE_STREAM_ID} | Retrieve a live stream +[**GetLiveStreamSimulcastTarget**](LiveStreamsApi.md#GetLiveStreamSimulcastTarget) | **Get** /video/v1/live-streams/{LIVE_STREAM_ID}/simulcast-targets/{SIMULCAST_TARGET_ID} | Retrieve a Live Stream Simulcast Target [**ListLiveStreams**](LiveStreamsApi.md#ListLiveStreams) | **Get** /video/v1/live-streams | List live streams [**ResetStreamKey**](LiveStreamsApi.md#ResetStreamKey) | **Post** /video/v1/live-streams/{LIVE_STREAM_ID}/reset-stream-key | Reset a live stream’s stream key [**SignalLiveStreamComplete**](LiveStreamsApi.md#SignalLiveStreamComplete) | **Put** /video/v1/live-streams/{LIVE_STREAM_ID}/complete | Signal a live stream is finished @@ -67,6 +70,35 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **CreateLiveStreamSimulcastTarget** +> SimulcastTargetResponse CreateLiveStreamSimulcastTarget(ctx, lIVESTREAMID, createSimulcastTargetRequest) +Create a live stream simulcast target + +Create a simulcast target for the parent live stream. Simulcast target can only be created when the parent live stream is in idle state. Only one simulcast target can be created at a time with this API. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **lIVESTREAMID** | **string**| The live stream ID | + **createSimulcastTargetRequest** | [**CreateSimulcastTargetRequest**](CreateSimulcastTargetRequest.md)| | + +### Return type + +[**SimulcastTargetResponse**](SimulcastTargetResponse.md) + +### Authorization + +[accessToken](../README.md#accessToken) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **DeleteLiveStream** > DeleteLiveStream(ctx, lIVESTREAMID) Delete a live stream @@ -120,6 +152,35 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **DeleteLiveStreamSimulcastTarget** +> DeleteLiveStreamSimulcastTarget(ctx, lIVESTREAMID, sIMULCASTTARGETID) +Delete a Live Stream Simulcast Target + +Delete the simulcast target using the simulcast target ID returned when creating the simulcast target. Simulcast Target can only be deleted when the parent live stream is in idle state. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **lIVESTREAMID** | **string**| The live stream ID | + **sIMULCASTTARGETID** | **string**| The ID of the simulcast target. | + +### Return type + + (empty response body) + +### Authorization + +[accessToken](../README.md#accessToken) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **GetLiveStream** > LiveStreamResponse GetLiveStream(ctx, lIVESTREAMID) Retrieve a live stream @@ -148,6 +209,35 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **GetLiveStreamSimulcastTarget** +> SimulcastTargetResponse GetLiveStreamSimulcastTarget(ctx, lIVESTREAMID, sIMULCASTTARGETID) +Retrieve a Live Stream Simulcast Target + +Retrieves the details of the simulcast target created for the parent live stream. Supply the unique live stream ID and simulcast target ID that was returned in the response of create simulcast target request, and Mux will return the corresponding information. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **lIVESTREAMID** | **string**| The live stream ID | + **sIMULCASTTARGETID** | **string**| The ID of the simulcast target. | + +### Return type + +[**SimulcastTargetResponse**](SimulcastTargetResponse.md) + +### Authorization + +[accessToken](../README.md#accessToken) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **ListLiveStreams** > ListLiveStreamsResponse ListLiveStreams(ctx, optional) List live streams diff --git a/docs/SigningKeyResponse.md b/docs/SigningKeyResponse.md index 935b556..2945625 100644 --- a/docs/SigningKeyResponse.md +++ b/docs/SigningKeyResponse.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Data** | [**SigningKey**](SigningKey.md) | | [optional] +**Data** | [**SigningKey**](.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) diff --git a/docs/SimulcastTarget.md b/docs/SimulcastTarget.md new file mode 100644 index 0000000..48a0045 --- /dev/null +++ b/docs/SimulcastTarget.md @@ -0,0 +1,14 @@ +# SimulcastTarget + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | ID of the Simulcast Target | [optional] +**Passthrough** | **string** | Arbitrary Metadata set when creating a simulcast target. | [optional] +**Status** | **string** | The current status of the simulcast target. See Statuses below for detailed description. * `idle`: Default status. When the parent live stream is in disconnected status, simulcast targets will be idle state. * `starting`: The simulcast target transitions into this state when the parent live stream transition into connected state. * `broadcasting`: The simulcast target has successfully connected to the third party live streaming service and is pushing video to that service. * `errored`: The simulcast target encountered an error either while attempting to connect to the third party live streaming service, or mid-broadcasting. Compared to other errored statuses in the Mux Video API, a simulcast may transition back into the broadcasting state if a connection with the service can be re-established. | [optional] +**StreamKey** | **string** | Stream Key represents an stream identifier for the third party live streaming service to simulcast the parent live stream too. | [optional] +**Url** | **string** | RTMP hostname including the application name for the third party live streaming service. | [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) + + diff --git a/docs/SimulcastTargetResponse.md b/docs/SimulcastTargetResponse.md new file mode 100644 index 0000000..e3619d6 --- /dev/null +++ b/docs/SimulcastTargetResponse.md @@ -0,0 +1,10 @@ +# SimulcastTargetResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Data** | [**SimulcastTarget**](.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) + + diff --git a/examples/common/lazytest.go b/examples/common/lazytest.go index 27683cb..887f8cd 100644 --- a/examples/common/lazytest.go +++ b/examples/common/lazytest.go @@ -26,7 +26,7 @@ func containsKind(kinds []reflect.Kind, kind reflect.Kind) bool { } // Copied from Testify under MIT license. -func AssertNotNil(o interface{}) { +func AssertNotNil(o interface{}) { if o == nil { fmt.Println("Object was nil!") os.Exit(255) @@ -47,6 +47,29 @@ func AssertNotNil(o interface{}) { } } +// Inverse of above +func AssertNil(o interface{}) { + if o == nil { + return + } + + v := reflect.ValueOf(o) + kind := v.Kind() + isNilableKind := containsKind( + []reflect.Kind{ + reflect.Chan, reflect.Func, + reflect.Interface, reflect.Map, + reflect.Ptr, reflect.Slice}, + kind) + + if isNilableKind && v.IsNil() { + return + } + + fmt.Println("Object nil!") + os.Exit(255) +} + func AssertStringEqualsValue(a string, b string) { if a != b { fmt.Println("Strings weren't equal!") diff --git a/examples/video/assets/exercise-assets.go b/examples/video/assets/exercise-assets.go index bed3719..8e16508 100644 --- a/examples/video/assets/exercise-assets.go +++ b/examples/video/assets/exercise-assets.go @@ -35,6 +35,7 @@ func main() { Url: "https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4", }, }, + NormalizeAudio: true, }) common.AssertNoError(err) common.AssertNotNil(asset.Data) diff --git a/examples/video/delivery-usage/exercise-delivery-usage.go b/examples/video/delivery-usage/exercise-delivery-usage.go new file mode 100644 index 0000000..130529a --- /dev/null +++ b/examples/video/delivery-usage/exercise-delivery-usage.go @@ -0,0 +1,36 @@ +package main + +import ( + "fmt" + "os" + "time" + + "github.com/muxinc/mux-go" + "github.com/muxinc/mux-go/examples/common" +) + +func main() { + + t := int32(time.Now().Unix()) + fmt.Println(t) + + + // API Client Initialization + client := muxgo.NewAPIClient( + muxgo.NewConfiguration( + muxgo.WithBasicAuth(os.Getenv("MUX_TOKEN_ID"), os.Getenv("MUX_TOKEN_SECRET")), + )) + + // ========== list-delivery-usage ========== + // OK, so here's the deal. Until we have actual meaningful data flowing into an account this is + // really hard to to test, so instead I just create a timeframe that's valid and call the API. + // We've manually verified this works during development. + // To use specific times: + // p := muxgo.ListDeliveryUsageParams{Timeframe: []string{"1574175600", "1574305200"}} + // du, err := client.DeliveryUsageApi.ListDeliveryUsage(muxgo.WithParams(&p)) + // Default time window is 1 hour representing usage from 13th to 12th hour from when the request is made. + du, err := client.DeliveryUsageApi.ListDeliveryUsage() + common.AssertNoError(err) + common.AssertNotNil(du.Data) + fmt.Println("list-delivery-usage OK ✅") +} \ No newline at end of file diff --git a/examples/video/live-streams/exercise-live-streams.go b/examples/video/live-streams/exercise-live-streams.go index 961c275..2646fbe 100644 --- a/examples/video/live-streams/exercise-live-streams.go +++ b/examples/video/live-streams/exercise-live-streams.go @@ -8,7 +8,7 @@ import ( "github.com/muxinc/mux-go/examples/common" ) -// Exercises all direct upload operations: +// Exercises all live stream operations: // create-live-stream // list-live-streams // get-live-stream @@ -17,6 +17,9 @@ import ( // delete-live-stream-playback-id // reset-stream-key // signal-live-stream-complete +// create-live-stream-simulcast-target +// get-live-stream-simulcast-target +// delete-live-stream-simulcast-target func main() { @@ -47,6 +50,30 @@ func main() { common.AssertNotNil(gs.Data) common.AssertStringEqualsValue(s.Data.Id, gs.Data.Id) fmt.Println("get-live-stream OK ✅") + + // ========== create-live-stream-simulcast-target ========== + cst := muxgo.CreateSimulcastTargetRequest{Passthrough: "foo", StreamKey: "bar", Url: "rtmp://this-is-a.test"} + nst, err := client.LiveStreamsApi.CreateLiveStreamSimulcastTarget(s.Data.Id, cst) + common.AssertNoError(err) + common.AssertNotNil(nst.Data) + fmt.Println("create-live-stream-simulcast-target OK ✅") + + // ========== get-live-stream-simulcast-target ========== + st, err := client.LiveStreamsApi.GetLiveStreamSimulcastTarget(s.Data.Id, nst.Data.Id) + common.AssertNoError(err) + common.AssertNotNil(st.Data) + common.AssertStringEqualsValue(nst.Data.Id, st.Data.Id) + fmt.Println("get-live-stream-simulcast-target OK ✅") + + // ========== delete-live-stream-simulcast-target ========== + err = client.LiveStreamsApi.DeleteLiveStreamSimulcastTarget(s.Data.Id, nst.Data.Id) + common.AssertNoError(err) + // Check it actually got deleted + snost, err := client.LiveStreamsApi.GetLiveStream(s.Data.Id) + common.AssertNoError(err) + common.AssertNotNil(snost.Data) + common.AssertNil(snost.Data.SimulcastTargets) + fmt.Println("delete-live-stream-simulcast-target OK ✅") // ========== create-live-stream-playback-id ========== cpbidr := muxgo.CreatePlaybackIdRequest{Policy: muxgo.SIGNED} diff --git a/model_asset.go b/model_asset.go index f7392fa..1e63cb4 100644 --- a/model_asset.go +++ b/model_asset.go @@ -23,5 +23,6 @@ type Asset struct { Master AssetMaster `json:"master,omitempty"` MasterAccess string `json:"master_access,omitempty"` Mp4Support string `json:"mp4_support,omitempty"` + NormalizeAudio bool `json:"normalize_audio,omitempty"` StaticRenditions AssetStaticRenditions `json:"static_renditions,omitempty"` } diff --git a/model_create_asset_request.go b/model_create_asset_request.go index 5d4e5a1..f3e866f 100644 --- a/model_create_asset_request.go +++ b/model_create_asset_request.go @@ -10,4 +10,7 @@ type CreateAssetRequest struct { PerTitleEncode bool `json:"per_title_encode,omitempty"` Passthrough string `json:"passthrough,omitempty"` Mp4Support string `json:"mp4_support,omitempty"` + // Normalize the audio track loudness level. This parameter is only applicable to on-demand (not live) assets. + NormalizeAudio bool `json:"normalize_audio,omitempty"` + MasterAccess string `json:"master_access,omitempty"` } diff --git a/model_create_live_stream_request.go b/model_create_live_stream_request.go index 680dd5d..521d965 100644 --- a/model_create_live_stream_request.go +++ b/model_create_live_stream_request.go @@ -6,7 +6,7 @@ package muxgo type CreateLiveStreamRequest struct { PlaybackPolicy []PlaybackPolicy `json:"playback_policy,omitempty"` NewAssetSettings CreateAssetRequest `json:"new_asset_settings,omitempty"` - // When live streaming software disconnects from Mux, either intentionally or due to a drop in the network, the Reconnect Window is the time in seconds that Mux should wait for the streaming software to reconnect before considering the live stream finished and completing the recorded asset. Default: 60 seconds + // When live streaming software disconnects from Mux, either intentionally or due to a drop in the network, the Reconnect Window is the time in seconds that Mux should wait for the streaming software to reconnect before considering the live stream finished and completing the recorded asset. Defaults to 60 seconds on the API if not specified. ReconnectWindow float32 `json:"reconnect_window,omitempty"` Passthrough string `json:"passthrough,omitempty"` // Latency is the time from when the streamer does something in real life to when you see it happen in the player. Set this if you want lower latency for your live stream. Note: Reconnect windows are incompatible with Reduced Latency and will always be set to zero (0) seconds. Read more here: https://mux.com/blog/reduced-latency-for-mux-live-streaming-now-available/ diff --git a/model_create_simulcast_target_request.go b/model_create_simulcast_target_request.go new file mode 100644 index 0000000..073cc7a --- /dev/null +++ b/model_create_simulcast_target_request.go @@ -0,0 +1,13 @@ +// Mux Go - Copyright 2019 Mux Inc. +// NOTE: This file is auto generated. Do not edit this file manually. + +package muxgo + +type CreateSimulcastTargetRequest struct { + // Arbitrary metadata set by you when creating a simulcast target. + Passthrough string `json:"passthrough,omitempty"` + // Stream Key represents a stream identifier on the third party live streaming service to send the parent live stream to. + StreamKey string `json:"stream_key,omitempty"` + // RTMP hostname including application name for the third party live streaming service. Example: 'rtmp://live.example.com/app'. + Url string `json:"url"` +} diff --git a/model_delivery_report.go b/model_delivery_report.go new file mode 100644 index 0000000..5e45838 --- /dev/null +++ b/model_delivery_report.go @@ -0,0 +1,14 @@ +// Mux Go - Copyright 2019 Mux Inc. +// NOTE: This file is auto generated. Do not edit this file manually. + +package muxgo + +type DeliveryReport struct { + LiveStreamId string `json:"live_stream_id,omitempty"` + AssetId string `json:"asset_id,omitempty"` + Passthrough string `json:"passthrough,omitempty"` + CreatedAt string `json:"created_at,omitempty"` + AssetState string `json:"asset_state,omitempty"` + AssetDuration float64 `json:"asset_duration,omitempty"` + DeliveredSeconds float64 `json:"delivered_seconds,omitempty"` +} diff --git a/model_list_delivery_usage_response.go b/model_list_delivery_usage_response.go new file mode 100644 index 0000000..af4de00 --- /dev/null +++ b/model_list_delivery_usage_response.go @@ -0,0 +1,12 @@ +// Mux Go - Copyright 2019 Mux Inc. +// NOTE: This file is auto generated. Do not edit this file manually. + +package muxgo + +type ListDeliveryUsageResponse struct { + Data []DeliveryReport `json:"data,omitempty"` + TotalRowCount int64 `json:"total_row_count,omitempty"` + Timeframe []int64 `json:"timeframe,omitempty"` + // Number of assets returned in this response. Default value is 100. + Limit int64 `json:"limit,omitempty"` +} diff --git a/model_live_stream.go b/model_live_stream.go index 54d3451..cdf12d9 100644 --- a/model_live_stream.go +++ b/model_live_stream.go @@ -4,15 +4,16 @@ package muxgo type LiveStream struct { - Id string `json:"id,omitempty"` - CreatedAt string `json:"created_at,omitempty"` - StreamKey string `json:"stream_key,omitempty"` - ActiveAssetId string `json:"active_asset_id,omitempty"` - RecentAssetIds []string `json:"recent_asset_ids,omitempty"` - Status string `json:"status,omitempty"` - PlaybackIds []PlaybackId `json:"playback_ids,omitempty"` - NewAssetSettings Asset `json:"new_asset_settings,omitempty"` - Passthrough string `json:"passthrough,omitempty"` - ReconnectWindow float64 `json:"reconnect_window,omitempty"` - ReducedLatency bool `json:"reduced_latency,omitempty"` + Id string `json:"id,omitempty"` + CreatedAt string `json:"created_at,omitempty"` + StreamKey string `json:"stream_key,omitempty"` + ActiveAssetId string `json:"active_asset_id,omitempty"` + RecentAssetIds []string `json:"recent_asset_ids,omitempty"` + Status string `json:"status,omitempty"` + PlaybackIds []PlaybackId `json:"playback_ids,omitempty"` + NewAssetSettings Asset `json:"new_asset_settings,omitempty"` + Passthrough string `json:"passthrough,omitempty"` + ReconnectWindow float32 `json:"reconnect_window,omitempty"` + ReducedLatency bool `json:"reduced_latency,omitempty"` + SimulcastTargets []SimulcastTarget `json:"simulcast_targets,omitempty"` } diff --git a/model_simulcast_target.go b/model_simulcast_target.go new file mode 100644 index 0000000..3ad3574 --- /dev/null +++ b/model_simulcast_target.go @@ -0,0 +1,17 @@ +// Mux Go - Copyright 2019 Mux Inc. +// NOTE: This file is auto generated. Do not edit this file manually. + +package muxgo + +type SimulcastTarget struct { + // ID of the Simulcast Target + Id string `json:"id,omitempty"` + // Arbitrary Metadata set when creating a simulcast target. + Passthrough string `json:"passthrough,omitempty"` + // The current status of the simulcast target. See Statuses below for detailed description. * `idle`: Default status. When the parent live stream is in disconnected status, simulcast targets will be idle state. * `starting`: The simulcast target transitions into this state when the parent live stream transition into connected state. * `broadcasting`: The simulcast target has successfully connected to the third party live streaming service and is pushing video to that service. * `errored`: The simulcast target encountered an error either while attempting to connect to the third party live streaming service, or mid-broadcasting. Compared to other errored statuses in the Mux Video API, a simulcast may transition back into the broadcasting state if a connection with the service can be re-established. + Status string `json:"status,omitempty"` + // Stream Key represents an stream identifier for the third party live streaming service to simulcast the parent live stream too. + StreamKey string `json:"stream_key,omitempty"` + // RTMP hostname including the application name for the third party live streaming service. + Url string `json:"url,omitempty"` +} diff --git a/model_simulcast_target_response.go b/model_simulcast_target_response.go new file mode 100644 index 0000000..a174b7a --- /dev/null +++ b/model_simulcast_target_response.go @@ -0,0 +1,8 @@ +// Mux Go - Copyright 2019 Mux Inc. +// NOTE: This file is auto generated. Do not edit this file manually. + +package muxgo + +type SimulcastTargetResponse struct { + Data SimulcastTarget `json:"data,omitempty"` +}