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