Skip to content

Commit

Permalink
Add support for master-access (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
philcluff authored Mar 12, 2020
1 parent f655cf5 commit 90f78c5
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 24 deletions.
77 changes: 77 additions & 0 deletions api_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,83 @@ func (a *AssetsApiService) ListAssets(opts ...APIOption) (ListAssetsResponse, er
return localVarReturnValue, nil
}

func (a *AssetsApiService) UpdateAssetMasterAccess(aSSETID string, updateAssetMasterAccessRequest UpdateAssetMasterAccessRequest, opts ...APIOption) (AssetResponse, error) {
var (
localVarAPIOptions = new(APIOptions)
localVarHttpMethod = strings.ToUpper("Put")
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue AssetResponse
)

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

// create path and map variables
localVarPath := a.client.cfg.basePath + "/video/v1/assets/{ASSET_ID}/master-access"
localVarPath = strings.Replace(localVarPath, "{"+"ASSET_ID"+"}", fmt.Sprintf("%v", aSSETID), -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 = &updateAssetMasterAccessRequest

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 *AssetsApiService) UpdateAssetMp4Support(aSSETID string, updateAssetMp4SupportRequest UpdateAssetMp4SupportRequest, opts ...APIOption) (AssetResponse, error) {
var (
localVarAPIOptions = new(APIOptions)
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.6.0",
userAgent: "Mux Go | 0.7.0",
}
for _, opt := range opts {
opt(cfg)
Expand Down
30 changes: 30 additions & 0 deletions docs/AssetsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Method | HTTP request | Description
[**GetAssetInputInfo**](AssetsApi.md#GetAssetInputInfo) | **Get** /video/v1/assets/{ASSET_ID}/input-info | Retrieve asset input info
[**GetAssetPlaybackId**](AssetsApi.md#GetAssetPlaybackId) | **Get** /video/v1/assets/{ASSET_ID}/playback-ids/{PLAYBACK_ID} | Retrieve a playback ID
[**ListAssets**](AssetsApi.md#ListAssets) | **Get** /video/v1/assets | List assets
[**UpdateAssetMasterAccess**](AssetsApi.md#UpdateAssetMasterAccess) | **Put** /video/v1/assets/{ASSET_ID}/master-access | Update master access
[**UpdateAssetMp4Support**](AssetsApi.md#UpdateAssetMp4Support) | **Put** /video/v1/assets/{ASSET_ID}/mp4-support | Update MP4 support


Expand Down Expand Up @@ -296,6 +297,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)

# **UpdateAssetMasterAccess**
> AssetResponse UpdateAssetMasterAccess(ctx, aSSETID, updateAssetMasterAccessRequest)
Update master access

Allows you add temporary access to the master (highest-quality) version of the asset in MP4 format. A URL will be created that can be used to download the master version for 24 hours. After 24 hours Master Access will revert to \"none\". This master version is not optimized for web and not meant to be streamed, only downloaded for purposes like archiving or editing the video offline.

### Required Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
**aSSETID** | **string**| The asset ID. |
**updateAssetMasterAccessRequest** | [**UpdateAssetMasterAccessRequest**](UpdateAssetMasterAccessRequest.md)| |

### Return type

[**AssetResponse**](AssetResponse.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)

# **UpdateAssetMp4Support**
> AssetResponse UpdateAssetMp4Support(ctx, aSSETID, updateAssetMp4SupportRequest)
Update MP4 support
Expand Down
10 changes: 10 additions & 0 deletions docs/UpdateAssetMasterAccessRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# UpdateAssetMasterAccessRequest

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**MasterAccess** | **string** | Add or remove access to the master version of the video. | [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)


44 changes: 21 additions & 23 deletions examples/video/assets/exercise-assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,10 @@ import (
"os"
"time"

"github.com/muxinc/mux-go"
muxgo "github.com/muxinc/mux-go"
"github.com/muxinc/mux-go/examples/common"
)

// Exercises all asset operations:
// get-asset
// delete-asset
// create-asset
// list-assets
// get-asset-input-info
// create-asset-playback-id
// get-asset-playback-id
// delete-asset-playback-id
// update-asset-mp4-support

func main() {

// API Client Initialization
Expand All @@ -35,12 +24,12 @@ func main() {
Url: "https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4",
},
muxgo.InputSettings{
Url: "https://tears-of-steel-subtitles.s3.amazonaws.com/tears-fr.vtt",
TextType : "subtitles",
Type: "text",
LanguageCode: "fr",
Url: "https://tears-of-steel-subtitles.s3.amazonaws.com/tears-fr.vtt",
TextType: "subtitles",
Type: "text",
LanguageCode: "fr",
ClosedCaptions: false,
Name: "French",
Name: "French",
},
},
NormalizeAudio: true,
Expand Down Expand Up @@ -104,14 +93,23 @@ func main() {
common.AssertStringEqualsValue(mp4.Data.Mp4Support, "standard")
fmt.Println("update-asset-mp4-support OK ✅")

// ========== update-asset-master-access ==========
mr := muxgo.UpdateAssetMasterAccessRequest{"temporary"}
mas, err := client.AssetsApi.UpdateAssetMasterAccess(asset.Data.Id, mr)
common.AssertNoError(err)
common.AssertNotNil(mas.Data)
common.AssertStringEqualsValue(asset.Data.Id, mas.Data.Id)
common.AssertStringEqualsValue(mas.Data.MasterAccess, "temporary")
fmt.Println("update-asset-master-access OK ✅")

// ========== create-asset-track ==========
cat := muxgo.CreateTrackRequest{
Url: "https://tears-of-steel-subtitles.s3.amazonaws.com/tears-en.vtt",
TextType : "subtitles",
Type: "text",
LanguageCode: "en",
Url: "https://tears-of-steel-subtitles.s3.amazonaws.com/tears-en.vtt",
TextType: "subtitles",
Type: "text",
LanguageCode: "en",
ClosedCaptions: false,
Name: "English",
Name: "English",
}
s, err := client.AssetsApi.CreateAssetTrack(asset.Data.Id, cat)
common.AssertNoError(err)
Expand All @@ -126,7 +124,7 @@ func main() {
err = client.AssetsApi.DeleteAssetTrack(asset.Data.Id, s.Data.Id)
common.AssertNoError(err)
a1s, err := client.AssetsApi.GetAsset(asset.Data.Id)
common.AssertIntEqualsValue(len(a1s.Data.Tracks), 3) // Audio, Video, French that we ingested with the asset
common.AssertIntEqualsValue(len(a1s.Data.Tracks), 3) // Audio, Video, French that we ingested with the asset
fmt.Println("delete-asset-track OK ✅")

// ========== delete-asset-playback-id ==========
Expand Down
9 changes: 9 additions & 0 deletions model_update_asset_master_access_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Mux Go - Copyright 2019 Mux Inc.
// NOTE: This file is auto generated. Do not edit this file manually.

package muxgo

type UpdateAssetMasterAccessRequest struct {
// Add or remove access to the master version of the video.
MasterAccess string `json:"master_access,omitempty"`
}

0 comments on commit 90f78c5

Please sign in to comment.