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