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/tracing" 25 "net/http" 26) 27 28// AssetsClient is the client for the Assets methods of the Media service. 29type AssetsClient struct { 30 BaseClient 31} 32 33// NewAssetsClient creates an instance of the AssetsClient client. 34func NewAssetsClient(subscriptionID string) AssetsClient { 35 return NewAssetsClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewAssetsClientWithBaseURI creates an instance of the AssetsClient client. 39func NewAssetsClientWithBaseURI(baseURI string, subscriptionID string) AssetsClient { 40 return AssetsClient{NewWithBaseURI(baseURI, subscriptionID)} 41} 42 43// CreateOrUpdate creates or updates an Asset in the Media Services account 44// Parameters: 45// resourceGroupName - the name of the resource group within the Azure subscription. 46// accountName - the Media Services account name. 47// assetName - the Asset name. 48// parameters - the request parameters 49func (client AssetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters Asset) (result Asset, err error) { 50 if tracing.IsEnabled() { 51 ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.CreateOrUpdate") 52 defer func() { 53 sc := -1 54 if result.Response.Response != nil { 55 sc = result.Response.Response.StatusCode 56 } 57 tracing.EndSpan(ctx, sc, err) 58 }() 59 } 60 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, assetName, parameters) 61 if err != nil { 62 err = autorest.NewErrorWithError(err, "media.AssetsClient", "CreateOrUpdate", nil, "Failure preparing request") 63 return 64 } 65 66 resp, err := client.CreateOrUpdateSender(req) 67 if err != nil { 68 result.Response = autorest.Response{Response: resp} 69 err = autorest.NewErrorWithError(err, "media.AssetsClient", "CreateOrUpdate", resp, "Failure sending request") 70 return 71 } 72 73 result, err = client.CreateOrUpdateResponder(resp) 74 if err != nil { 75 err = autorest.NewErrorWithError(err, "media.AssetsClient", "CreateOrUpdate", resp, "Failure responding to request") 76 } 77 78 return 79} 80 81// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 82func (client AssetsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters Asset) (*http.Request, error) { 83 pathParameters := map[string]interface{}{ 84 "accountName": autorest.Encode("path", accountName), 85 "assetName": autorest.Encode("path", assetName), 86 "resourceGroupName": autorest.Encode("path", resourceGroupName), 87 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 88 } 89 90 const APIVersion = "2018-03-30-preview" 91 queryParameters := map[string]interface{}{ 92 "api-version": APIVersion, 93 } 94 95 preparer := autorest.CreatePreparer( 96 autorest.AsContentType("application/json; charset=utf-8"), 97 autorest.AsPut(), 98 autorest.WithBaseURL(client.BaseURI), 99 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", pathParameters), 100 autorest.WithJSON(parameters), 101 autorest.WithQueryParameters(queryParameters)) 102 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 103} 104 105// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 106// http.Response Body if it receives an error. 107func (client AssetsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 108 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 109 return autorest.SendWithSender(client, req, sd...) 110} 111 112// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 113// closes the http.Response Body. 114func (client AssetsClient) CreateOrUpdateResponder(resp *http.Response) (result Asset, err error) { 115 err = autorest.Respond( 116 resp, 117 client.ByInspecting(), 118 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 119 autorest.ByUnmarshallingJSON(&result), 120 autorest.ByClosing()) 121 result.Response = autorest.Response{Response: resp} 122 return 123} 124 125// Delete deletes an Asset in the Media Services account 126// Parameters: 127// resourceGroupName - the name of the resource group within the Azure subscription. 128// accountName - the Media Services account name. 129// assetName - the Asset name. 130func (client AssetsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, assetName string) (result autorest.Response, err error) { 131 if tracing.IsEnabled() { 132 ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.Delete") 133 defer func() { 134 sc := -1 135 if result.Response != nil { 136 sc = result.Response.StatusCode 137 } 138 tracing.EndSpan(ctx, sc, err) 139 }() 140 } 141 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, assetName) 142 if err != nil { 143 err = autorest.NewErrorWithError(err, "media.AssetsClient", "Delete", nil, "Failure preparing request") 144 return 145 } 146 147 resp, err := client.DeleteSender(req) 148 if err != nil { 149 result.Response = resp 150 err = autorest.NewErrorWithError(err, "media.AssetsClient", "Delete", resp, "Failure sending request") 151 return 152 } 153 154 result, err = client.DeleteResponder(resp) 155 if err != nil { 156 err = autorest.NewErrorWithError(err, "media.AssetsClient", "Delete", resp, "Failure responding to request") 157 } 158 159 return 160} 161 162// DeletePreparer prepares the Delete request. 163func (client AssetsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string) (*http.Request, error) { 164 pathParameters := map[string]interface{}{ 165 "accountName": autorest.Encode("path", accountName), 166 "assetName": autorest.Encode("path", assetName), 167 "resourceGroupName": autorest.Encode("path", resourceGroupName), 168 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 169 } 170 171 const APIVersion = "2018-03-30-preview" 172 queryParameters := map[string]interface{}{ 173 "api-version": APIVersion, 174 } 175 176 preparer := autorest.CreatePreparer( 177 autorest.AsDelete(), 178 autorest.WithBaseURL(client.BaseURI), 179 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", pathParameters), 180 autorest.WithQueryParameters(queryParameters)) 181 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 182} 183 184// DeleteSender sends the Delete request. The method will close the 185// http.Response Body if it receives an error. 186func (client AssetsClient) DeleteSender(req *http.Request) (*http.Response, error) { 187 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 188 return autorest.SendWithSender(client, req, sd...) 189} 190 191// DeleteResponder handles the response to the Delete request. The method always 192// closes the http.Response Body. 193func (client AssetsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 194 err = autorest.Respond( 195 resp, 196 client.ByInspecting(), 197 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 198 autorest.ByClosing()) 199 result.Response = resp 200 return 201} 202 203// Get get the details of an Asset in the Media Services account 204// Parameters: 205// resourceGroupName - the name of the resource group within the Azure subscription. 206// accountName - the Media Services account name. 207// assetName - the Asset name. 208func (client AssetsClient) Get(ctx context.Context, resourceGroupName string, accountName string, assetName string) (result Asset, err error) { 209 if tracing.IsEnabled() { 210 ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.Get") 211 defer func() { 212 sc := -1 213 if result.Response.Response != nil { 214 sc = result.Response.Response.StatusCode 215 } 216 tracing.EndSpan(ctx, sc, err) 217 }() 218 } 219 req, err := client.GetPreparer(ctx, resourceGroupName, accountName, assetName) 220 if err != nil { 221 err = autorest.NewErrorWithError(err, "media.AssetsClient", "Get", nil, "Failure preparing request") 222 return 223 } 224 225 resp, err := client.GetSender(req) 226 if err != nil { 227 result.Response = autorest.Response{Response: resp} 228 err = autorest.NewErrorWithError(err, "media.AssetsClient", "Get", resp, "Failure sending request") 229 return 230 } 231 232 result, err = client.GetResponder(resp) 233 if err != nil { 234 err = autorest.NewErrorWithError(err, "media.AssetsClient", "Get", resp, "Failure responding to request") 235 } 236 237 return 238} 239 240// GetPreparer prepares the Get request. 241func (client AssetsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string) (*http.Request, error) { 242 pathParameters := map[string]interface{}{ 243 "accountName": autorest.Encode("path", accountName), 244 "assetName": autorest.Encode("path", assetName), 245 "resourceGroupName": autorest.Encode("path", resourceGroupName), 246 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 247 } 248 249 const APIVersion = "2018-03-30-preview" 250 queryParameters := map[string]interface{}{ 251 "api-version": APIVersion, 252 } 253 254 preparer := autorest.CreatePreparer( 255 autorest.AsGet(), 256 autorest.WithBaseURL(client.BaseURI), 257 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", pathParameters), 258 autorest.WithQueryParameters(queryParameters)) 259 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 260} 261 262// GetSender sends the Get request. The method will close the 263// http.Response Body if it receives an error. 264func (client AssetsClient) GetSender(req *http.Request) (*http.Response, error) { 265 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 266 return autorest.SendWithSender(client, req, sd...) 267} 268 269// GetResponder handles the response to the Get request. The method always 270// closes the http.Response Body. 271func (client AssetsClient) GetResponder(resp *http.Response) (result Asset, err error) { 272 err = autorest.Respond( 273 resp, 274 client.ByInspecting(), 275 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), 276 autorest.ByUnmarshallingJSON(&result), 277 autorest.ByClosing()) 278 result.Response = autorest.Response{Response: resp} 279 return 280} 281 282// GetEncryptionKey gets the Asset storage encryption keys used to decrypt content created by version 2 of the Media 283// Services API 284// Parameters: 285// resourceGroupName - the name of the resource group within the Azure subscription. 286// accountName - the Media Services account name. 287// assetName - the Asset name. 288func (client AssetsClient) GetEncryptionKey(ctx context.Context, resourceGroupName string, accountName string, assetName string) (result AssetStorageEncryptionKey, err error) { 289 if tracing.IsEnabled() { 290 ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.GetEncryptionKey") 291 defer func() { 292 sc := -1 293 if result.Response.Response != nil { 294 sc = result.Response.Response.StatusCode 295 } 296 tracing.EndSpan(ctx, sc, err) 297 }() 298 } 299 req, err := client.GetEncryptionKeyPreparer(ctx, resourceGroupName, accountName, assetName) 300 if err != nil { 301 err = autorest.NewErrorWithError(err, "media.AssetsClient", "GetEncryptionKey", nil, "Failure preparing request") 302 return 303 } 304 305 resp, err := client.GetEncryptionKeySender(req) 306 if err != nil { 307 result.Response = autorest.Response{Response: resp} 308 err = autorest.NewErrorWithError(err, "media.AssetsClient", "GetEncryptionKey", resp, "Failure sending request") 309 return 310 } 311 312 result, err = client.GetEncryptionKeyResponder(resp) 313 if err != nil { 314 err = autorest.NewErrorWithError(err, "media.AssetsClient", "GetEncryptionKey", resp, "Failure responding to request") 315 } 316 317 return 318} 319 320// GetEncryptionKeyPreparer prepares the GetEncryptionKey request. 321func (client AssetsClient) GetEncryptionKeyPreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string) (*http.Request, error) { 322 pathParameters := map[string]interface{}{ 323 "accountName": autorest.Encode("path", accountName), 324 "assetName": autorest.Encode("path", assetName), 325 "resourceGroupName": autorest.Encode("path", resourceGroupName), 326 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 327 } 328 329 const APIVersion = "2018-03-30-preview" 330 queryParameters := map[string]interface{}{ 331 "api-version": APIVersion, 332 } 333 334 preparer := autorest.CreatePreparer( 335 autorest.AsPost(), 336 autorest.WithBaseURL(client.BaseURI), 337 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/getEncryptionKey", pathParameters), 338 autorest.WithQueryParameters(queryParameters)) 339 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 340} 341 342// GetEncryptionKeySender sends the GetEncryptionKey request. The method will close the 343// http.Response Body if it receives an error. 344func (client AssetsClient) GetEncryptionKeySender(req *http.Request) (*http.Response, error) { 345 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 346 return autorest.SendWithSender(client, req, sd...) 347} 348 349// GetEncryptionKeyResponder handles the response to the GetEncryptionKey request. The method always 350// closes the http.Response Body. 351func (client AssetsClient) GetEncryptionKeyResponder(resp *http.Response) (result AssetStorageEncryptionKey, err error) { 352 err = autorest.Respond( 353 resp, 354 client.ByInspecting(), 355 azure.WithErrorUnlessStatusCode(http.StatusOK), 356 autorest.ByUnmarshallingJSON(&result), 357 autorest.ByClosing()) 358 result.Response = autorest.Response{Response: resp} 359 return 360} 361 362// List list Assets in the Media Services account with optional filtering and ordering 363// Parameters: 364// resourceGroupName - the name of the resource group within the Azure subscription. 365// accountName - the Media Services account name. 366// filter - restricts the set of items returned. 367// top - specifies a non-negative integer n that limits the number of items returned from a collection. The 368// service returns the number of available items up to but not greater than the specified value n. 369// orderby - specifies the key by which the result collection should be ordered. 370func (client AssetsClient) List(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, orderby string) (result AssetCollectionPage, err error) { 371 if tracing.IsEnabled() { 372 ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.List") 373 defer func() { 374 sc := -1 375 if result.ac.Response.Response != nil { 376 sc = result.ac.Response.Response.StatusCode 377 } 378 tracing.EndSpan(ctx, sc, err) 379 }() 380 } 381 result.fn = client.listNextResults 382 req, err := client.ListPreparer(ctx, resourceGroupName, accountName, filter, top, orderby) 383 if err != nil { 384 err = autorest.NewErrorWithError(err, "media.AssetsClient", "List", nil, "Failure preparing request") 385 return 386 } 387 388 resp, err := client.ListSender(req) 389 if err != nil { 390 result.ac.Response = autorest.Response{Response: resp} 391 err = autorest.NewErrorWithError(err, "media.AssetsClient", "List", resp, "Failure sending request") 392 return 393 } 394 395 result.ac, err = client.ListResponder(resp) 396 if err != nil { 397 err = autorest.NewErrorWithError(err, "media.AssetsClient", "List", resp, "Failure responding to request") 398 } 399 400 return 401} 402 403// ListPreparer prepares the List request. 404func (client AssetsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, orderby string) (*http.Request, error) { 405 pathParameters := map[string]interface{}{ 406 "accountName": autorest.Encode("path", accountName), 407 "resourceGroupName": autorest.Encode("path", resourceGroupName), 408 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 409 } 410 411 const APIVersion = "2018-03-30-preview" 412 queryParameters := map[string]interface{}{ 413 "api-version": APIVersion, 414 } 415 if len(filter) > 0 { 416 queryParameters["$filter"] = autorest.Encode("query", filter) 417 } 418 if top != nil { 419 queryParameters["$top"] = autorest.Encode("query", *top) 420 } 421 if len(orderby) > 0 { 422 queryParameters["$orderby"] = autorest.Encode("query", orderby) 423 } 424 425 preparer := autorest.CreatePreparer( 426 autorest.AsGet(), 427 autorest.WithBaseURL(client.BaseURI), 428 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets", pathParameters), 429 autorest.WithQueryParameters(queryParameters)) 430 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 431} 432 433// ListSender sends the List request. The method will close the 434// http.Response Body if it receives an error. 435func (client AssetsClient) ListSender(req *http.Request) (*http.Response, error) { 436 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 437 return autorest.SendWithSender(client, req, sd...) 438} 439 440// ListResponder handles the response to the List request. The method always 441// closes the http.Response Body. 442func (client AssetsClient) ListResponder(resp *http.Response) (result AssetCollection, err error) { 443 err = autorest.Respond( 444 resp, 445 client.ByInspecting(), 446 azure.WithErrorUnlessStatusCode(http.StatusOK), 447 autorest.ByUnmarshallingJSON(&result), 448 autorest.ByClosing()) 449 result.Response = autorest.Response{Response: resp} 450 return 451} 452 453// listNextResults retrieves the next set of results, if any. 454func (client AssetsClient) listNextResults(ctx context.Context, lastResults AssetCollection) (result AssetCollection, err error) { 455 req, err := lastResults.assetCollectionPreparer(ctx) 456 if err != nil { 457 return result, autorest.NewErrorWithError(err, "media.AssetsClient", "listNextResults", nil, "Failure preparing next results request") 458 } 459 if req == nil { 460 return 461 } 462 resp, err := client.ListSender(req) 463 if err != nil { 464 result.Response = autorest.Response{Response: resp} 465 return result, autorest.NewErrorWithError(err, "media.AssetsClient", "listNextResults", resp, "Failure sending next results request") 466 } 467 result, err = client.ListResponder(resp) 468 if err != nil { 469 err = autorest.NewErrorWithError(err, "media.AssetsClient", "listNextResults", resp, "Failure responding to next results request") 470 } 471 return 472} 473 474// ListComplete enumerates all values, automatically crossing page boundaries as required. 475func (client AssetsClient) ListComplete(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, orderby string) (result AssetCollectionIterator, err error) { 476 if tracing.IsEnabled() { 477 ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.List") 478 defer func() { 479 sc := -1 480 if result.Response().Response.Response != nil { 481 sc = result.page.Response().Response.Response.StatusCode 482 } 483 tracing.EndSpan(ctx, sc, err) 484 }() 485 } 486 result.page, err = client.List(ctx, resourceGroupName, accountName, filter, top, orderby) 487 return 488} 489 490// ListContainerSas lists storage container URLs with shared access signatures (SAS) for uploading and downloading 491// Asset content. The signatures are derived from the storage account keys. 492// Parameters: 493// resourceGroupName - the name of the resource group within the Azure subscription. 494// accountName - the Media Services account name. 495// assetName - the Asset name. 496// parameters - the request parameters 497func (client AssetsClient) ListContainerSas(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters ListContainerSasInput) (result AssetContainerSas, err error) { 498 if tracing.IsEnabled() { 499 ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.ListContainerSas") 500 defer func() { 501 sc := -1 502 if result.Response.Response != nil { 503 sc = result.Response.Response.StatusCode 504 } 505 tracing.EndSpan(ctx, sc, err) 506 }() 507 } 508 req, err := client.ListContainerSasPreparer(ctx, resourceGroupName, accountName, assetName, parameters) 509 if err != nil { 510 err = autorest.NewErrorWithError(err, "media.AssetsClient", "ListContainerSas", nil, "Failure preparing request") 511 return 512 } 513 514 resp, err := client.ListContainerSasSender(req) 515 if err != nil { 516 result.Response = autorest.Response{Response: resp} 517 err = autorest.NewErrorWithError(err, "media.AssetsClient", "ListContainerSas", resp, "Failure sending request") 518 return 519 } 520 521 result, err = client.ListContainerSasResponder(resp) 522 if err != nil { 523 err = autorest.NewErrorWithError(err, "media.AssetsClient", "ListContainerSas", resp, "Failure responding to request") 524 } 525 526 return 527} 528 529// ListContainerSasPreparer prepares the ListContainerSas request. 530func (client AssetsClient) ListContainerSasPreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters ListContainerSasInput) (*http.Request, error) { 531 pathParameters := map[string]interface{}{ 532 "accountName": autorest.Encode("path", accountName), 533 "assetName": autorest.Encode("path", assetName), 534 "resourceGroupName": autorest.Encode("path", resourceGroupName), 535 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 536 } 537 538 const APIVersion = "2018-03-30-preview" 539 queryParameters := map[string]interface{}{ 540 "api-version": APIVersion, 541 } 542 543 preparer := autorest.CreatePreparer( 544 autorest.AsContentType("application/json; charset=utf-8"), 545 autorest.AsPost(), 546 autorest.WithBaseURL(client.BaseURI), 547 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}/listContainerSas", pathParameters), 548 autorest.WithJSON(parameters), 549 autorest.WithQueryParameters(queryParameters)) 550 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 551} 552 553// ListContainerSasSender sends the ListContainerSas request. The method will close the 554// http.Response Body if it receives an error. 555func (client AssetsClient) ListContainerSasSender(req *http.Request) (*http.Response, error) { 556 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 557 return autorest.SendWithSender(client, req, sd...) 558} 559 560// ListContainerSasResponder handles the response to the ListContainerSas request. The method always 561// closes the http.Response Body. 562func (client AssetsClient) ListContainerSasResponder(resp *http.Response) (result AssetContainerSas, err error) { 563 err = autorest.Respond( 564 resp, 565 client.ByInspecting(), 566 azure.WithErrorUnlessStatusCode(http.StatusOK), 567 autorest.ByUnmarshallingJSON(&result), 568 autorest.ByClosing()) 569 result.Response = autorest.Response{Response: resp} 570 return 571} 572 573// Update updates an existing Asset in the Media Services account 574// Parameters: 575// resourceGroupName - the name of the resource group within the Azure subscription. 576// accountName - the Media Services account name. 577// assetName - the Asset name. 578// parameters - the request parameters 579func (client AssetsClient) Update(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters Asset) (result Asset, err error) { 580 if tracing.IsEnabled() { 581 ctx = tracing.StartSpan(ctx, fqdn+"/AssetsClient.Update") 582 defer func() { 583 sc := -1 584 if result.Response.Response != nil { 585 sc = result.Response.Response.StatusCode 586 } 587 tracing.EndSpan(ctx, sc, err) 588 }() 589 } 590 req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, assetName, parameters) 591 if err != nil { 592 err = autorest.NewErrorWithError(err, "media.AssetsClient", "Update", nil, "Failure preparing request") 593 return 594 } 595 596 resp, err := client.UpdateSender(req) 597 if err != nil { 598 result.Response = autorest.Response{Response: resp} 599 err = autorest.NewErrorWithError(err, "media.AssetsClient", "Update", resp, "Failure sending request") 600 return 601 } 602 603 result, err = client.UpdateResponder(resp) 604 if err != nil { 605 err = autorest.NewErrorWithError(err, "media.AssetsClient", "Update", resp, "Failure responding to request") 606 } 607 608 return 609} 610 611// UpdatePreparer prepares the Update request. 612func (client AssetsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, assetName string, parameters Asset) (*http.Request, error) { 613 pathParameters := map[string]interface{}{ 614 "accountName": autorest.Encode("path", accountName), 615 "assetName": autorest.Encode("path", assetName), 616 "resourceGroupName": autorest.Encode("path", resourceGroupName), 617 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 618 } 619 620 const APIVersion = "2018-03-30-preview" 621 queryParameters := map[string]interface{}{ 622 "api-version": APIVersion, 623 } 624 625 preparer := autorest.CreatePreparer( 626 autorest.AsContentType("application/json; charset=utf-8"), 627 autorest.AsPatch(), 628 autorest.WithBaseURL(client.BaseURI), 629 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/assets/{assetName}", pathParameters), 630 autorest.WithJSON(parameters), 631 autorest.WithQueryParameters(queryParameters)) 632 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 633} 634 635// UpdateSender sends the Update request. The method will close the 636// http.Response Body if it receives an error. 637func (client AssetsClient) UpdateSender(req *http.Request) (*http.Response, error) { 638 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 639 return autorest.SendWithSender(client, req, sd...) 640} 641 642// UpdateResponder handles the response to the Update request. The method always 643// closes the http.Response Body. 644func (client AssetsClient) UpdateResponder(resp *http.Response) (result Asset, err error) { 645 err = autorest.Respond( 646 resp, 647 client.ByInspecting(), 648 azure.WithErrorUnlessStatusCode(http.StatusOK), 649 autorest.ByUnmarshallingJSON(&result), 650 autorest.ByClosing()) 651 result.Response = autorest.Response{Response: resp} 652 return 653} 654