...

Source file src/github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl/servicefabrics.go

Documentation: github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl

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

View as plain text