package media // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( "context" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/tracing" "net/http" ) // TracksClient is the client for the Tracks methods of the Media service. type TracksClient struct { BaseClient } // NewTracksClient creates an instance of the TracksClient client. func NewTracksClient(subscriptionID string) TracksClient { return NewTracksClientWithBaseURI(DefaultBaseURI, subscriptionID) } // NewTracksClientWithBaseURI creates an instance of the TracksClient client using a custom endpoint. Use this when // interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). func NewTracksClientWithBaseURI(baseURI string, subscriptionID string) TracksClient { return TracksClient{NewWithBaseURI(baseURI, subscriptionID)} } // CreateOrUpdate create or update a Track in the asset // Parameters: // resourceGroupName - the name of the resource group within the Azure subscription. // accountName - the Media Services account name. // assetName - the Asset name. // trackName - the Asset Track name. // parameters - the request parameters func (client TracksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, parameters AssetTrack) (result TracksCreateOrUpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TracksClient.CreateOrUpdate") defer func() { sc := -1 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { sc = result.FutureAPI.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() } req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, assetName, trackName, parameters) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "CreateOrUpdate", nil, "Failure preparing request") return } result, err = client.CreateOrUpdateSender(req) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "CreateOrUpdate", result.Response(), "Failure sending request") return } return } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client TracksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, parameters AssetTrack) (*http.Request, error) { pathParameters := map[string]interface{}{ "accountName": autorest.Encode("path", accountName), "assetName": autorest.Encode("path", assetName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), "trackName": autorest.Encode("path", trackName), } const APIVersion = "2021-11-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}", pathParameters), autorest.WithJSON(parameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the // http.Response Body if it receives an error. func (client TracksClient) CreateOrUpdateSender(req *http.Request) (future TracksCreateOrUpdateFuture, err error) { var resp *http.Response future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return } var azf azure.Future azf, err = azure.NewFutureFromResponse(resp) future.FutureAPI = &azf future.Result = future.result return } // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // closes the http.Response Body. func (client TracksClient) CreateOrUpdateResponder(resp *http.Response) (result AssetTrack, err error) { err = autorest.Respond( resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // Delete deletes a Track in the asset // Parameters: // resourceGroupName - the name of the resource group within the Azure subscription. // accountName - the Media Services account name. // assetName - the Asset name. // trackName - the Asset Track name. func (client TracksClient) Delete(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string) (result TracksDeleteFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TracksClient.Delete") defer func() { sc := -1 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { sc = result.FutureAPI.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() } req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, assetName, trackName) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "Delete", nil, "Failure preparing request") return } result, err = client.DeleteSender(req) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "Delete", result.Response(), "Failure sending request") return } return } // DeletePreparer prepares the Delete request. func (client TracksClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "accountName": autorest.Encode("path", accountName), "assetName": autorest.Encode("path", assetName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), "trackName": autorest.Encode("path", trackName), } const APIVersion = "2021-11-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } // DeleteSender sends the Delete request. The method will close the // http.Response Body if it receives an error. func (client TracksClient) DeleteSender(req *http.Request) (future TracksDeleteFuture, err error) { var resp *http.Response future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return } var azf azure.Future azf, err = azure.NewFutureFromResponse(resp) future.FutureAPI = &azf future.Result = future.result return } // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. func (client TracksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), autorest.ByClosing()) result.Response = resp return } // Get get the details of a Track in the Asset // Parameters: // resourceGroupName - the name of the resource group within the Azure subscription. // accountName - the Media Services account name. // assetName - the Asset name. // trackName - the Asset Track name. func (client TracksClient) Get(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string) (result AssetTrack, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TracksClient.Get") defer func() { sc := -1 if result.Response.Response != nil { sc = result.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } req, err := client.GetPreparer(ctx, resourceGroupName, accountName, assetName, trackName) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "Get", nil, "Failure preparing request") return } resp, err := client.GetSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "media.TracksClient", "Get", resp, "Failure sending request") return } result, err = client.GetResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "Get", resp, "Failure responding to request") return } return } // GetPreparer prepares the Get request. func (client TracksClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "accountName": autorest.Encode("path", accountName), "assetName": autorest.Encode("path", assetName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), "trackName": autorest.Encode("path", trackName), } const APIVersion = "2021-11-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } // GetSender sends the Get request. The method will close the // http.Response Body if it receives an error. func (client TracksClient) GetSender(req *http.Request) (*http.Response, error) { return client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // GetResponder handles the response to the Get request. The method always // closes the http.Response Body. func (client TracksClient) GetResponder(resp *http.Response) (result AssetTrack, err error) { err = autorest.Respond( resp, azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // List lists the Tracks in the asset // Parameters: // resourceGroupName - the name of the resource group within the Azure subscription. // accountName - the Media Services account name. // assetName - the Asset name. func (client TracksClient) List(ctx context.Context, resourceGroupName string, accountName string, assetName string) (result AssetTrackCollection, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TracksClient.List") defer func() { sc := -1 if result.Response.Response != nil { sc = result.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } req, err := client.ListPreparer(ctx, resourceGroupName, accountName, assetName) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "List", nil, "Failure preparing request") return } resp, err := client.ListSender(req) if err != nil { result.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "media.TracksClient", "List", resp, "Failure sending request") return } result, err = client.ListResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "List", resp, "Failure responding to request") return } return } // ListPreparer prepares the List request. func (client TracksClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "accountName": autorest.Encode("path", accountName), "assetName": autorest.Encode("path", assetName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } const APIVersion = "2021-11-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } // ListSender sends the List request. The method will close the // http.Response Body if it receives an error. func (client TracksClient) ListSender(req *http.Request) (*http.Response, error) { return client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. func (client TracksClient) ListResponder(resp *http.Response) (result AssetTrackCollection, err error) { err = autorest.Respond( resp, azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // Update updates an existing Track in the asset // Parameters: // resourceGroupName - the name of the resource group within the Azure subscription. // accountName - the Media Services account name. // assetName - the Asset name. // trackName - the Asset Track name. // parameters - the request parameters func (client TracksClient) Update(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, parameters AssetTrack) (result TracksUpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TracksClient.Update") defer func() { sc := -1 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { sc = result.FutureAPI.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() } req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, assetName, trackName, parameters) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "Update", nil, "Failure preparing request") return } result, err = client.UpdateSender(req) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "Update", result.Response(), "Failure sending request") return } return } // UpdatePreparer prepares the Update request. func (client TracksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string, parameters AssetTrack) (*http.Request, error) { pathParameters := map[string]interface{}{ "accountName": autorest.Encode("path", accountName), "assetName": autorest.Encode("path", assetName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), "trackName": autorest.Encode("path", trackName), } const APIVersion = "2021-11-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPatch(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}", pathParameters), autorest.WithJSON(parameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } // UpdateSender sends the Update request. The method will close the // http.Response Body if it receives an error. func (client TracksClient) UpdateSender(req *http.Request) (future TracksUpdateFuture, err error) { var resp *http.Response future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return } var azf azure.Future azf, err = azure.NewFutureFromResponse(resp) future.FutureAPI = &azf future.Result = future.result return } // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. func (client TracksClient) UpdateResponder(resp *http.Response) (result AssetTrack, err error) { err = autorest.Respond( resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} return } // UpdateTrackData update the track data. Call this API after any changes are made to the track data stored in the // asset container. For example, you have modified the WebVTT captions file in the Azure blob storage container for the // asset, viewers will not see the new version of the captions unless this API is called. Note, the changes may not be // reflected immediately. CDN cache may also need to be purged if applicable. // Parameters: // resourceGroupName - the name of the resource group within the Azure subscription. // accountName - the Media Services account name. // assetName - the Asset name. // trackName - the Asset Track name. func (client TracksClient) UpdateTrackData(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string) (result TracksUpdateTrackDataFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TracksClient.UpdateTrackData") defer func() { sc := -1 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { sc = result.FutureAPI.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() } req, err := client.UpdateTrackDataPreparer(ctx, resourceGroupName, accountName, assetName, trackName) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "UpdateTrackData", nil, "Failure preparing request") return } result, err = client.UpdateTrackDataSender(req) if err != nil { err = autorest.NewErrorWithError(err, "media.TracksClient", "UpdateTrackData", result.Response(), "Failure sending request") return } return } // UpdateTrackDataPreparer prepares the UpdateTrackData request. func (client TracksClient) UpdateTrackDataPreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, trackName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "accountName": autorest.Encode("path", accountName), "assetName": autorest.Encode("path", assetName), "resourceGroupName": autorest.Encode("path", resourceGroupName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), "trackName": autorest.Encode("path", trackName), } const APIVersion = "2021-11-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/tracks/{trackName}/updateTrackData", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } // UpdateTrackDataSender sends the UpdateTrackData request. The method will close the // http.Response Body if it receives an error. func (client TracksClient) UpdateTrackDataSender(req *http.Request) (future TracksUpdateTrackDataFuture, err error) { var resp *http.Response future.FutureAPI = &azure.Future{} resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) if err != nil { return } var azf azure.Future azf, err = azure.NewFutureFromResponse(resp) future.FutureAPI = &azf future.Result = future.result return } // UpdateTrackDataResponder handles the response to the UpdateTrackData request. The method always // closes the http.Response Body. func (client TracksClient) UpdateTrackDataResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByClosing()) result.Response = resp return }