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