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