...

Source file src/github.com/Azure/azure-sdk-for-go/services/mediaservices/mgmt/2021-11-01/media/liveevents.go

Documentation: github.com/Azure/azure-sdk-for-go/services/mediaservices/mgmt/2021-11-01/media

     1  package media
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // LiveEventsClient is the client for the LiveEvents methods of the Media service.
    19  type LiveEventsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewLiveEventsClient creates an instance of the LiveEventsClient client.
    24  func NewLiveEventsClient(subscriptionID string) LiveEventsClient {
    25  	return NewLiveEventsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewLiveEventsClientWithBaseURI creates an instance of the LiveEventsClient client using a custom endpoint.  Use this
    29  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewLiveEventsClientWithBaseURI(baseURI string, subscriptionID string) LiveEventsClient {
    31  	return LiveEventsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Allocate a live event is in StandBy state after allocation completes, and is ready to start.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group within the Azure subscription.
    37  // accountName - the Media Services account name.
    38  // liveEventName - the name of the live event, maximum length is 32.
    39  func (client LiveEventsClient) Allocate(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (result LiveEventsAllocateFuture, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/LiveEventsClient.Allocate")
    42  		defer func() {
    43  			sc := -1
    44  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    45  				sc = result.FutureAPI.Response().StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	if err := validation.Validate([]validation.Validation{
    51  		{TargetValue: liveEventName,
    52  			Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
    53  				{Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
    54  				{Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
    55  		return result, validation.NewError("media.LiveEventsClient", "Allocate", err.Error())
    56  	}
    57  
    58  	req, err := client.AllocatePreparer(ctx, resourceGroupName, accountName, liveEventName)
    59  	if err != nil {
    60  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Allocate", nil, "Failure preparing request")
    61  		return
    62  	}
    63  
    64  	result, err = client.AllocateSender(req)
    65  	if err != nil {
    66  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Allocate", result.Response(), "Failure sending request")
    67  		return
    68  	}
    69  
    70  	return
    71  }
    72  
    73  // AllocatePreparer prepares the Allocate request.
    74  func (client LiveEventsClient) AllocatePreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (*http.Request, error) {
    75  	pathParameters := map[string]interface{}{
    76  		"accountName":       autorest.Encode("path", accountName),
    77  		"liveEventName":     autorest.Encode("path", liveEventName),
    78  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    79  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    80  	}
    81  
    82  	const APIVersion = "2021-11-01"
    83  	queryParameters := map[string]interface{}{
    84  		"api-version": APIVersion,
    85  	}
    86  
    87  	preparer := autorest.CreatePreparer(
    88  		autorest.AsPost(),
    89  		autorest.WithBaseURL(client.BaseURI),
    90  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/allocate", pathParameters),
    91  		autorest.WithQueryParameters(queryParameters))
    92  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    93  }
    94  
    95  // AllocateSender sends the Allocate request. The method will close the
    96  // http.Response Body if it receives an error.
    97  func (client LiveEventsClient) AllocateSender(req *http.Request) (future LiveEventsAllocateFuture, err error) {
    98  	var resp *http.Response
    99  	future.FutureAPI = &azure.Future{}
   100  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   101  	if err != nil {
   102  		return
   103  	}
   104  	var azf azure.Future
   105  	azf, err = azure.NewFutureFromResponse(resp)
   106  	future.FutureAPI = &azf
   107  	future.Result = future.result
   108  	return
   109  }
   110  
   111  // AllocateResponder handles the response to the Allocate request. The method always
   112  // closes the http.Response Body.
   113  func (client LiveEventsClient) AllocateResponder(resp *http.Response) (result autorest.Response, err error) {
   114  	err = autorest.Respond(
   115  		resp,
   116  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   117  		autorest.ByClosing())
   118  	result.Response = resp
   119  	return
   120  }
   121  
   122  // Create creates a new live event.
   123  // Parameters:
   124  // resourceGroupName - the name of the resource group within the Azure subscription.
   125  // accountName - the Media Services account name.
   126  // liveEventName - the name of the live event, maximum length is 32.
   127  // parameters - live event properties needed for creation.
   128  // autoStart - the flag indicates if the resource should be automatically started on creation.
   129  func (client LiveEventsClient) Create(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEvent, autoStart *bool) (result LiveEventsCreateFuture, err error) {
   130  	if tracing.IsEnabled() {
   131  		ctx = tracing.StartSpan(ctx, fqdn+"/LiveEventsClient.Create")
   132  		defer func() {
   133  			sc := -1
   134  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   135  				sc = result.FutureAPI.Response().StatusCode
   136  			}
   137  			tracing.EndSpan(ctx, sc, err)
   138  		}()
   139  	}
   140  	if err := validation.Validate([]validation.Validation{
   141  		{TargetValue: liveEventName,
   142  			Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
   143  				{Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
   144  				{Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}},
   145  		{TargetValue: parameters,
   146  			Constraints: []validation.Constraint{{Target: "parameters.LiveEventProperties", Name: validation.Null, Rule: false,
   147  				Chain: []validation.Constraint{{Target: "parameters.LiveEventProperties.Input", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
   148  		return result, validation.NewError("media.LiveEventsClient", "Create", err.Error())
   149  	}
   150  
   151  	req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, liveEventName, parameters, autoStart)
   152  	if err != nil {
   153  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Create", nil, "Failure preparing request")
   154  		return
   155  	}
   156  
   157  	result, err = client.CreateSender(req)
   158  	if err != nil {
   159  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Create", result.Response(), "Failure sending request")
   160  		return
   161  	}
   162  
   163  	return
   164  }
   165  
   166  // CreatePreparer prepares the Create request.
   167  func (client LiveEventsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEvent, autoStart *bool) (*http.Request, error) {
   168  	pathParameters := map[string]interface{}{
   169  		"accountName":       autorest.Encode("path", accountName),
   170  		"liveEventName":     autorest.Encode("path", liveEventName),
   171  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   172  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   173  	}
   174  
   175  	const APIVersion = "2021-11-01"
   176  	queryParameters := map[string]interface{}{
   177  		"api-version": APIVersion,
   178  	}
   179  	if autoStart != nil {
   180  		queryParameters["autoStart"] = autorest.Encode("query", *autoStart)
   181  	}
   182  
   183  	parameters.SystemData = nil
   184  	preparer := autorest.CreatePreparer(
   185  		autorest.AsContentType("application/json; charset=utf-8"),
   186  		autorest.AsPut(),
   187  		autorest.WithBaseURL(client.BaseURI),
   188  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}", pathParameters),
   189  		autorest.WithJSON(parameters),
   190  		autorest.WithQueryParameters(queryParameters))
   191  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   192  }
   193  
   194  // CreateSender sends the Create request. The method will close the
   195  // http.Response Body if it receives an error.
   196  func (client LiveEventsClient) CreateSender(req *http.Request) (future LiveEventsCreateFuture, err error) {
   197  	var resp *http.Response
   198  	future.FutureAPI = &azure.Future{}
   199  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   200  	if err != nil {
   201  		return
   202  	}
   203  	var azf azure.Future
   204  	azf, err = azure.NewFutureFromResponse(resp)
   205  	future.FutureAPI = &azf
   206  	future.Result = future.result
   207  	return
   208  }
   209  
   210  // CreateResponder handles the response to the Create request. The method always
   211  // closes the http.Response Body.
   212  func (client LiveEventsClient) CreateResponder(resp *http.Response) (result LiveEvent, err error) {
   213  	err = autorest.Respond(
   214  		resp,
   215  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   216  		autorest.ByUnmarshallingJSON(&result),
   217  		autorest.ByClosing())
   218  	result.Response = autorest.Response{Response: resp}
   219  	return
   220  }
   221  
   222  // Delete deletes a live event.
   223  // Parameters:
   224  // resourceGroupName - the name of the resource group within the Azure subscription.
   225  // accountName - the Media Services account name.
   226  // liveEventName - the name of the live event, maximum length is 32.
   227  func (client LiveEventsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (result LiveEventsDeleteFuture, err error) {
   228  	if tracing.IsEnabled() {
   229  		ctx = tracing.StartSpan(ctx, fqdn+"/LiveEventsClient.Delete")
   230  		defer func() {
   231  			sc := -1
   232  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   233  				sc = result.FutureAPI.Response().StatusCode
   234  			}
   235  			tracing.EndSpan(ctx, sc, err)
   236  		}()
   237  	}
   238  	if err := validation.Validate([]validation.Validation{
   239  		{TargetValue: liveEventName,
   240  			Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
   241  				{Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
   242  				{Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
   243  		return result, validation.NewError("media.LiveEventsClient", "Delete", err.Error())
   244  	}
   245  
   246  	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, liveEventName)
   247  	if err != nil {
   248  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Delete", nil, "Failure preparing request")
   249  		return
   250  	}
   251  
   252  	result, err = client.DeleteSender(req)
   253  	if err != nil {
   254  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Delete", result.Response(), "Failure sending request")
   255  		return
   256  	}
   257  
   258  	return
   259  }
   260  
   261  // DeletePreparer prepares the Delete request.
   262  func (client LiveEventsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (*http.Request, error) {
   263  	pathParameters := map[string]interface{}{
   264  		"accountName":       autorest.Encode("path", accountName),
   265  		"liveEventName":     autorest.Encode("path", liveEventName),
   266  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   267  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   268  	}
   269  
   270  	const APIVersion = "2021-11-01"
   271  	queryParameters := map[string]interface{}{
   272  		"api-version": APIVersion,
   273  	}
   274  
   275  	preparer := autorest.CreatePreparer(
   276  		autorest.AsDelete(),
   277  		autorest.WithBaseURL(client.BaseURI),
   278  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}", pathParameters),
   279  		autorest.WithQueryParameters(queryParameters))
   280  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   281  }
   282  
   283  // DeleteSender sends the Delete request. The method will close the
   284  // http.Response Body if it receives an error.
   285  func (client LiveEventsClient) DeleteSender(req *http.Request) (future LiveEventsDeleteFuture, err error) {
   286  	var resp *http.Response
   287  	future.FutureAPI = &azure.Future{}
   288  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   289  	if err != nil {
   290  		return
   291  	}
   292  	var azf azure.Future
   293  	azf, err = azure.NewFutureFromResponse(resp)
   294  	future.FutureAPI = &azf
   295  	future.Result = future.result
   296  	return
   297  }
   298  
   299  // DeleteResponder handles the response to the Delete request. The method always
   300  // closes the http.Response Body.
   301  func (client LiveEventsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   302  	err = autorest.Respond(
   303  		resp,
   304  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   305  		autorest.ByClosing())
   306  	result.Response = resp
   307  	return
   308  }
   309  
   310  // Get gets properties of a live event.
   311  // Parameters:
   312  // resourceGroupName - the name of the resource group within the Azure subscription.
   313  // accountName - the Media Services account name.
   314  // liveEventName - the name of the live event, maximum length is 32.
   315  func (client LiveEventsClient) Get(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (result LiveEvent, err error) {
   316  	if tracing.IsEnabled() {
   317  		ctx = tracing.StartSpan(ctx, fqdn+"/LiveEventsClient.Get")
   318  		defer func() {
   319  			sc := -1
   320  			if result.Response.Response != nil {
   321  				sc = result.Response.Response.StatusCode
   322  			}
   323  			tracing.EndSpan(ctx, sc, err)
   324  		}()
   325  	}
   326  	if err := validation.Validate([]validation.Validation{
   327  		{TargetValue: liveEventName,
   328  			Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
   329  				{Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
   330  				{Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
   331  		return result, validation.NewError("media.LiveEventsClient", "Get", err.Error())
   332  	}
   333  
   334  	req, err := client.GetPreparer(ctx, resourceGroupName, accountName, liveEventName)
   335  	if err != nil {
   336  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Get", nil, "Failure preparing request")
   337  		return
   338  	}
   339  
   340  	resp, err := client.GetSender(req)
   341  	if err != nil {
   342  		result.Response = autorest.Response{Response: resp}
   343  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Get", resp, "Failure sending request")
   344  		return
   345  	}
   346  
   347  	result, err = client.GetResponder(resp)
   348  	if err != nil {
   349  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Get", resp, "Failure responding to request")
   350  		return
   351  	}
   352  
   353  	return
   354  }
   355  
   356  // GetPreparer prepares the Get request.
   357  func (client LiveEventsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (*http.Request, error) {
   358  	pathParameters := map[string]interface{}{
   359  		"accountName":       autorest.Encode("path", accountName),
   360  		"liveEventName":     autorest.Encode("path", liveEventName),
   361  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   362  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   363  	}
   364  
   365  	const APIVersion = "2021-11-01"
   366  	queryParameters := map[string]interface{}{
   367  		"api-version": APIVersion,
   368  	}
   369  
   370  	preparer := autorest.CreatePreparer(
   371  		autorest.AsGet(),
   372  		autorest.WithBaseURL(client.BaseURI),
   373  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}", pathParameters),
   374  		autorest.WithQueryParameters(queryParameters))
   375  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   376  }
   377  
   378  // GetSender sends the Get request. The method will close the
   379  // http.Response Body if it receives an error.
   380  func (client LiveEventsClient) GetSender(req *http.Request) (*http.Response, error) {
   381  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   382  }
   383  
   384  // GetResponder handles the response to the Get request. The method always
   385  // closes the http.Response Body.
   386  func (client LiveEventsClient) GetResponder(resp *http.Response) (result LiveEvent, err error) {
   387  	err = autorest.Respond(
   388  		resp,
   389  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   390  		autorest.ByUnmarshallingJSON(&result),
   391  		autorest.ByClosing())
   392  	result.Response = autorest.Response{Response: resp}
   393  	return
   394  }
   395  
   396  // List lists all the live events in the account.
   397  // Parameters:
   398  // resourceGroupName - the name of the resource group within the Azure subscription.
   399  // accountName - the Media Services account name.
   400  func (client LiveEventsClient) List(ctx context.Context, resourceGroupName string, accountName string) (result LiveEventListResultPage, err error) {
   401  	if tracing.IsEnabled() {
   402  		ctx = tracing.StartSpan(ctx, fqdn+"/LiveEventsClient.List")
   403  		defer func() {
   404  			sc := -1
   405  			if result.lelr.Response.Response != nil {
   406  				sc = result.lelr.Response.Response.StatusCode
   407  			}
   408  			tracing.EndSpan(ctx, sc, err)
   409  		}()
   410  	}
   411  	result.fn = client.listNextResults
   412  	req, err := client.ListPreparer(ctx, resourceGroupName, accountName)
   413  	if err != nil {
   414  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "List", nil, "Failure preparing request")
   415  		return
   416  	}
   417  
   418  	resp, err := client.ListSender(req)
   419  	if err != nil {
   420  		result.lelr.Response = autorest.Response{Response: resp}
   421  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "List", resp, "Failure sending request")
   422  		return
   423  	}
   424  
   425  	result.lelr, err = client.ListResponder(resp)
   426  	if err != nil {
   427  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "List", resp, "Failure responding to request")
   428  		return
   429  	}
   430  	if result.lelr.hasNextLink() && result.lelr.IsEmpty() {
   431  		err = result.NextWithContext(ctx)
   432  		return
   433  	}
   434  
   435  	return
   436  }
   437  
   438  // ListPreparer prepares the List request.
   439  func (client LiveEventsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
   440  	pathParameters := map[string]interface{}{
   441  		"accountName":       autorest.Encode("path", accountName),
   442  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   443  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   444  	}
   445  
   446  	const APIVersion = "2021-11-01"
   447  	queryParameters := map[string]interface{}{
   448  		"api-version": APIVersion,
   449  	}
   450  
   451  	preparer := autorest.CreatePreparer(
   452  		autorest.AsGet(),
   453  		autorest.WithBaseURL(client.BaseURI),
   454  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents", pathParameters),
   455  		autorest.WithQueryParameters(queryParameters))
   456  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   457  }
   458  
   459  // ListSender sends the List request. The method will close the
   460  // http.Response Body if it receives an error.
   461  func (client LiveEventsClient) ListSender(req *http.Request) (*http.Response, error) {
   462  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   463  }
   464  
   465  // ListResponder handles the response to the List request. The method always
   466  // closes the http.Response Body.
   467  func (client LiveEventsClient) ListResponder(resp *http.Response) (result LiveEventListResult, err error) {
   468  	err = autorest.Respond(
   469  		resp,
   470  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   471  		autorest.ByUnmarshallingJSON(&result),
   472  		autorest.ByClosing())
   473  	result.Response = autorest.Response{Response: resp}
   474  	return
   475  }
   476  
   477  // listNextResults retrieves the next set of results, if any.
   478  func (client LiveEventsClient) listNextResults(ctx context.Context, lastResults LiveEventListResult) (result LiveEventListResult, err error) {
   479  	req, err := lastResults.liveEventListResultPreparer(ctx)
   480  	if err != nil {
   481  		return result, autorest.NewErrorWithError(err, "media.LiveEventsClient", "listNextResults", nil, "Failure preparing next results request")
   482  	}
   483  	if req == nil {
   484  		return
   485  	}
   486  	resp, err := client.ListSender(req)
   487  	if err != nil {
   488  		result.Response = autorest.Response{Response: resp}
   489  		return result, autorest.NewErrorWithError(err, "media.LiveEventsClient", "listNextResults", resp, "Failure sending next results request")
   490  	}
   491  	result, err = client.ListResponder(resp)
   492  	if err != nil {
   493  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "listNextResults", resp, "Failure responding to next results request")
   494  	}
   495  	return
   496  }
   497  
   498  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   499  func (client LiveEventsClient) ListComplete(ctx context.Context, resourceGroupName string, accountName string) (result LiveEventListResultIterator, err error) {
   500  	if tracing.IsEnabled() {
   501  		ctx = tracing.StartSpan(ctx, fqdn+"/LiveEventsClient.List")
   502  		defer func() {
   503  			sc := -1
   504  			if result.Response().Response.Response != nil {
   505  				sc = result.page.Response().Response.Response.StatusCode
   506  			}
   507  			tracing.EndSpan(ctx, sc, err)
   508  		}()
   509  	}
   510  	result.page, err = client.List(ctx, resourceGroupName, accountName)
   511  	return
   512  }
   513  
   514  // Reset resets an existing live event. All live outputs for the live event are deleted and the live event is stopped
   515  // and will be started again. All assets used by the live outputs and streaming locators created on these assets are
   516  // unaffected.
   517  // Parameters:
   518  // resourceGroupName - the name of the resource group within the Azure subscription.
   519  // accountName - the Media Services account name.
   520  // liveEventName - the name of the live event, maximum length is 32.
   521  func (client LiveEventsClient) Reset(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (result LiveEventsResetFuture, err error) {
   522  	if tracing.IsEnabled() {
   523  		ctx = tracing.StartSpan(ctx, fqdn+"/LiveEventsClient.Reset")
   524  		defer func() {
   525  			sc := -1
   526  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   527  				sc = result.FutureAPI.Response().StatusCode
   528  			}
   529  			tracing.EndSpan(ctx, sc, err)
   530  		}()
   531  	}
   532  	if err := validation.Validate([]validation.Validation{
   533  		{TargetValue: liveEventName,
   534  			Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
   535  				{Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
   536  				{Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
   537  		return result, validation.NewError("media.LiveEventsClient", "Reset", err.Error())
   538  	}
   539  
   540  	req, err := client.ResetPreparer(ctx, resourceGroupName, accountName, liveEventName)
   541  	if err != nil {
   542  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Reset", nil, "Failure preparing request")
   543  		return
   544  	}
   545  
   546  	result, err = client.ResetSender(req)
   547  	if err != nil {
   548  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Reset", result.Response(), "Failure sending request")
   549  		return
   550  	}
   551  
   552  	return
   553  }
   554  
   555  // ResetPreparer prepares the Reset request.
   556  func (client LiveEventsClient) ResetPreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (*http.Request, error) {
   557  	pathParameters := map[string]interface{}{
   558  		"accountName":       autorest.Encode("path", accountName),
   559  		"liveEventName":     autorest.Encode("path", liveEventName),
   560  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   561  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   562  	}
   563  
   564  	const APIVersion = "2021-11-01"
   565  	queryParameters := map[string]interface{}{
   566  		"api-version": APIVersion,
   567  	}
   568  
   569  	preparer := autorest.CreatePreparer(
   570  		autorest.AsPost(),
   571  		autorest.WithBaseURL(client.BaseURI),
   572  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/reset", pathParameters),
   573  		autorest.WithQueryParameters(queryParameters))
   574  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   575  }
   576  
   577  // ResetSender sends the Reset request. The method will close the
   578  // http.Response Body if it receives an error.
   579  func (client LiveEventsClient) ResetSender(req *http.Request) (future LiveEventsResetFuture, err error) {
   580  	var resp *http.Response
   581  	future.FutureAPI = &azure.Future{}
   582  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   583  	if err != nil {
   584  		return
   585  	}
   586  	var azf azure.Future
   587  	azf, err = azure.NewFutureFromResponse(resp)
   588  	future.FutureAPI = &azf
   589  	future.Result = future.result
   590  	return
   591  }
   592  
   593  // ResetResponder handles the response to the Reset request. The method always
   594  // closes the http.Response Body.
   595  func (client LiveEventsClient) ResetResponder(resp *http.Response) (result autorest.Response, err error) {
   596  	err = autorest.Respond(
   597  		resp,
   598  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   599  		autorest.ByClosing())
   600  	result.Response = resp
   601  	return
   602  }
   603  
   604  // Start a live event in Stopped or StandBy state will be in Running state after the start operation completes.
   605  // Parameters:
   606  // resourceGroupName - the name of the resource group within the Azure subscription.
   607  // accountName - the Media Services account name.
   608  // liveEventName - the name of the live event, maximum length is 32.
   609  func (client LiveEventsClient) Start(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (result LiveEventsStartFuture, err error) {
   610  	if tracing.IsEnabled() {
   611  		ctx = tracing.StartSpan(ctx, fqdn+"/LiveEventsClient.Start")
   612  		defer func() {
   613  			sc := -1
   614  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   615  				sc = result.FutureAPI.Response().StatusCode
   616  			}
   617  			tracing.EndSpan(ctx, sc, err)
   618  		}()
   619  	}
   620  	if err := validation.Validate([]validation.Validation{
   621  		{TargetValue: liveEventName,
   622  			Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
   623  				{Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
   624  				{Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
   625  		return result, validation.NewError("media.LiveEventsClient", "Start", err.Error())
   626  	}
   627  
   628  	req, err := client.StartPreparer(ctx, resourceGroupName, accountName, liveEventName)
   629  	if err != nil {
   630  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Start", nil, "Failure preparing request")
   631  		return
   632  	}
   633  
   634  	result, err = client.StartSender(req)
   635  	if err != nil {
   636  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Start", result.Response(), "Failure sending request")
   637  		return
   638  	}
   639  
   640  	return
   641  }
   642  
   643  // StartPreparer prepares the Start request.
   644  func (client LiveEventsClient) StartPreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string) (*http.Request, error) {
   645  	pathParameters := map[string]interface{}{
   646  		"accountName":       autorest.Encode("path", accountName),
   647  		"liveEventName":     autorest.Encode("path", liveEventName),
   648  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   649  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   650  	}
   651  
   652  	const APIVersion = "2021-11-01"
   653  	queryParameters := map[string]interface{}{
   654  		"api-version": APIVersion,
   655  	}
   656  
   657  	preparer := autorest.CreatePreparer(
   658  		autorest.AsPost(),
   659  		autorest.WithBaseURL(client.BaseURI),
   660  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/start", pathParameters),
   661  		autorest.WithQueryParameters(queryParameters))
   662  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   663  }
   664  
   665  // StartSender sends the Start request. The method will close the
   666  // http.Response Body if it receives an error.
   667  func (client LiveEventsClient) StartSender(req *http.Request) (future LiveEventsStartFuture, err error) {
   668  	var resp *http.Response
   669  	future.FutureAPI = &azure.Future{}
   670  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   671  	if err != nil {
   672  		return
   673  	}
   674  	var azf azure.Future
   675  	azf, err = azure.NewFutureFromResponse(resp)
   676  	future.FutureAPI = &azf
   677  	future.Result = future.result
   678  	return
   679  }
   680  
   681  // StartResponder handles the response to the Start request. The method always
   682  // closes the http.Response Body.
   683  func (client LiveEventsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) {
   684  	err = autorest.Respond(
   685  		resp,
   686  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   687  		autorest.ByClosing())
   688  	result.Response = resp
   689  	return
   690  }
   691  
   692  // Stop stops a running live event.
   693  // Parameters:
   694  // resourceGroupName - the name of the resource group within the Azure subscription.
   695  // accountName - the Media Services account name.
   696  // liveEventName - the name of the live event, maximum length is 32.
   697  // parameters - liveEvent stop parameters
   698  func (client LiveEventsClient) Stop(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEventActionInput) (result LiveEventsStopFuture, err error) {
   699  	if tracing.IsEnabled() {
   700  		ctx = tracing.StartSpan(ctx, fqdn+"/LiveEventsClient.Stop")
   701  		defer func() {
   702  			sc := -1
   703  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   704  				sc = result.FutureAPI.Response().StatusCode
   705  			}
   706  			tracing.EndSpan(ctx, sc, err)
   707  		}()
   708  	}
   709  	if err := validation.Validate([]validation.Validation{
   710  		{TargetValue: liveEventName,
   711  			Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
   712  				{Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
   713  				{Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
   714  		return result, validation.NewError("media.LiveEventsClient", "Stop", err.Error())
   715  	}
   716  
   717  	req, err := client.StopPreparer(ctx, resourceGroupName, accountName, liveEventName, parameters)
   718  	if err != nil {
   719  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Stop", nil, "Failure preparing request")
   720  		return
   721  	}
   722  
   723  	result, err = client.StopSender(req)
   724  	if err != nil {
   725  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Stop", result.Response(), "Failure sending request")
   726  		return
   727  	}
   728  
   729  	return
   730  }
   731  
   732  // StopPreparer prepares the Stop request.
   733  func (client LiveEventsClient) StopPreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEventActionInput) (*http.Request, error) {
   734  	pathParameters := map[string]interface{}{
   735  		"accountName":       autorest.Encode("path", accountName),
   736  		"liveEventName":     autorest.Encode("path", liveEventName),
   737  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   738  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   739  	}
   740  
   741  	const APIVersion = "2021-11-01"
   742  	queryParameters := map[string]interface{}{
   743  		"api-version": APIVersion,
   744  	}
   745  
   746  	preparer := autorest.CreatePreparer(
   747  		autorest.AsContentType("application/json; charset=utf-8"),
   748  		autorest.AsPost(),
   749  		autorest.WithBaseURL(client.BaseURI),
   750  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/stop", pathParameters),
   751  		autorest.WithJSON(parameters),
   752  		autorest.WithQueryParameters(queryParameters))
   753  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   754  }
   755  
   756  // StopSender sends the Stop request. The method will close the
   757  // http.Response Body if it receives an error.
   758  func (client LiveEventsClient) StopSender(req *http.Request) (future LiveEventsStopFuture, err error) {
   759  	var resp *http.Response
   760  	future.FutureAPI = &azure.Future{}
   761  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   762  	if err != nil {
   763  		return
   764  	}
   765  	var azf azure.Future
   766  	azf, err = azure.NewFutureFromResponse(resp)
   767  	future.FutureAPI = &azf
   768  	future.Result = future.result
   769  	return
   770  }
   771  
   772  // StopResponder handles the response to the Stop request. The method always
   773  // closes the http.Response Body.
   774  func (client LiveEventsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) {
   775  	err = autorest.Respond(
   776  		resp,
   777  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   778  		autorest.ByClosing())
   779  	result.Response = resp
   780  	return
   781  }
   782  
   783  // Update updates settings on an existing live event.
   784  // Parameters:
   785  // resourceGroupName - the name of the resource group within the Azure subscription.
   786  // accountName - the Media Services account name.
   787  // liveEventName - the name of the live event, maximum length is 32.
   788  // parameters - live event properties needed for patch.
   789  func (client LiveEventsClient) Update(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEvent) (result LiveEventsUpdateFuture, err error) {
   790  	if tracing.IsEnabled() {
   791  		ctx = tracing.StartSpan(ctx, fqdn+"/LiveEventsClient.Update")
   792  		defer func() {
   793  			sc := -1
   794  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   795  				sc = result.FutureAPI.Response().StatusCode
   796  			}
   797  			tracing.EndSpan(ctx, sc, err)
   798  		}()
   799  	}
   800  	if err := validation.Validate([]validation.Validation{
   801  		{TargetValue: liveEventName,
   802  			Constraints: []validation.Constraint{{Target: "liveEventName", Name: validation.MaxLength, Rule: 32, Chain: nil},
   803  				{Target: "liveEventName", Name: validation.MinLength, Rule: 1, Chain: nil},
   804  				{Target: "liveEventName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil {
   805  		return result, validation.NewError("media.LiveEventsClient", "Update", err.Error())
   806  	}
   807  
   808  	req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, liveEventName, parameters)
   809  	if err != nil {
   810  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Update", nil, "Failure preparing request")
   811  		return
   812  	}
   813  
   814  	result, err = client.UpdateSender(req)
   815  	if err != nil {
   816  		err = autorest.NewErrorWithError(err, "media.LiveEventsClient", "Update", result.Response(), "Failure sending request")
   817  		return
   818  	}
   819  
   820  	return
   821  }
   822  
   823  // UpdatePreparer prepares the Update request.
   824  func (client LiveEventsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, parameters LiveEvent) (*http.Request, error) {
   825  	pathParameters := map[string]interface{}{
   826  		"accountName":       autorest.Encode("path", accountName),
   827  		"liveEventName":     autorest.Encode("path", liveEventName),
   828  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   829  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   830  	}
   831  
   832  	const APIVersion = "2021-11-01"
   833  	queryParameters := map[string]interface{}{
   834  		"api-version": APIVersion,
   835  	}
   836  
   837  	parameters.SystemData = nil
   838  	preparer := autorest.CreatePreparer(
   839  		autorest.AsContentType("application/json; charset=utf-8"),
   840  		autorest.AsPatch(),
   841  		autorest.WithBaseURL(client.BaseURI),
   842  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}", pathParameters),
   843  		autorest.WithJSON(parameters),
   844  		autorest.WithQueryParameters(queryParameters))
   845  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   846  }
   847  
   848  // UpdateSender sends the Update request. The method will close the
   849  // http.Response Body if it receives an error.
   850  func (client LiveEventsClient) UpdateSender(req *http.Request) (future LiveEventsUpdateFuture, err error) {
   851  	var resp *http.Response
   852  	future.FutureAPI = &azure.Future{}
   853  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   854  	if err != nil {
   855  		return
   856  	}
   857  	var azf azure.Future
   858  	azf, err = azure.NewFutureFromResponse(resp)
   859  	future.FutureAPI = &azf
   860  	future.Result = future.result
   861  	return
   862  }
   863  
   864  // UpdateResponder handles the response to the Update request. The method always
   865  // closes the http.Response Body.
   866  func (client LiveEventsClient) UpdateResponder(resp *http.Response) (result LiveEvent, err error) {
   867  	err = autorest.Respond(
   868  		resp,
   869  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   870  		autorest.ByUnmarshallingJSON(&result),
   871  		autorest.ByClosing())
   872  	result.Response = autorest.Response{Response: resp}
   873  	return
   874  }
   875  

View as plain text