...

Source file src/github.com/Azure/azure-sdk-for-go/services/mediaservices/mgmt/2018-07-01/media/streamingendpoints.go

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

View as plain text