...

Source file src/github.com/Azure/azure-sdk-for-go/services/domainservices/mgmt/2017-01-01/aad/domainservices.go

Documentation: github.com/Azure/azure-sdk-for-go/services/domainservices/mgmt/2017-01-01/aad

     1  package aad
     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  // DomainServicesClient is the the AAD Domain Services API.
    19  type DomainServicesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewDomainServicesClient creates an instance of the DomainServicesClient client.
    24  func NewDomainServicesClient(subscriptionID string) DomainServicesClient {
    25  	return NewDomainServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewDomainServicesClientWithBaseURI creates an instance of the DomainServicesClient 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 NewDomainServicesClientWithBaseURI(baseURI string, subscriptionID string) DomainServicesClient {
    31  	return DomainServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // CreateOrUpdate the Create Domain Service operation creates a new domain service with the specified parameters. If
    35  // the specific service already exists, then any patchable properties will be updated and any immutable properties will
    36  // remain unchanged.
    37  // Parameters:
    38  // resourceGroupName - the name of the resource group within the user's subscription. The name is case
    39  // insensitive.
    40  // domainServiceName - the name of the domain service.
    41  // domainService - properties supplied to the Create or Update a Domain Service operation.
    42  func (client DomainServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, domainServiceName string, domainService DomainService) (result DomainServicesCreateOrUpdateFuture, err error) {
    43  	if tracing.IsEnabled() {
    44  		ctx = tracing.StartSpan(ctx, fqdn+"/DomainServicesClient.CreateOrUpdate")
    45  		defer func() {
    46  			sc := -1
    47  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    48  				sc = result.FutureAPI.Response().StatusCode
    49  			}
    50  			tracing.EndSpan(ctx, sc, err)
    51  		}()
    52  	}
    53  	if err := validation.Validate([]validation.Validation{
    54  		{TargetValue: resourceGroupName,
    55  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    56  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    57  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
    58  		return result, validation.NewError("aad.DomainServicesClient", "CreateOrUpdate", err.Error())
    59  	}
    60  
    61  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, domainServiceName, domainService)
    62  	if err != nil {
    63  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "CreateOrUpdate", nil, "Failure preparing request")
    64  		return
    65  	}
    66  
    67  	result, err = client.CreateOrUpdateSender(req)
    68  	if err != nil {
    69  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
    70  		return
    71  	}
    72  
    73  	return
    74  }
    75  
    76  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    77  func (client DomainServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, domainServiceName string, domainService DomainService) (*http.Request, error) {
    78  	pathParameters := map[string]interface{}{
    79  		"domainServiceName": autorest.Encode("path", domainServiceName),
    80  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    81  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    82  	}
    83  
    84  	const APIVersion = "2017-01-01"
    85  	queryParameters := map[string]interface{}{
    86  		"api-version": APIVersion,
    87  	}
    88  
    89  	preparer := autorest.CreatePreparer(
    90  		autorest.AsContentType("application/json; charset=utf-8"),
    91  		autorest.AsPut(),
    92  		autorest.WithBaseURL(client.BaseURI),
    93  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AAD/domainServices/{domainServiceName}", pathParameters),
    94  		autorest.WithJSON(domainService),
    95  		autorest.WithQueryParameters(queryParameters))
    96  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    97  }
    98  
    99  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   100  // http.Response Body if it receives an error.
   101  func (client DomainServicesClient) CreateOrUpdateSender(req *http.Request) (future DomainServicesCreateOrUpdateFuture, err error) {
   102  	var resp *http.Response
   103  	future.FutureAPI = &azure.Future{}
   104  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   105  	if err != nil {
   106  		return
   107  	}
   108  	var azf azure.Future
   109  	azf, err = azure.NewFutureFromResponse(resp)
   110  	future.FutureAPI = &azf
   111  	future.Result = future.result
   112  	return
   113  }
   114  
   115  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   116  // closes the http.Response Body.
   117  func (client DomainServicesClient) CreateOrUpdateResponder(resp *http.Response) (result DomainService, err error) {
   118  	err = autorest.Respond(
   119  		resp,
   120  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
   121  		autorest.ByUnmarshallingJSON(&result),
   122  		autorest.ByClosing())
   123  	result.Response = autorest.Response{Response: resp}
   124  	return
   125  }
   126  
   127  // Delete the Delete Domain Service operation deletes an existing Domain Service.
   128  // Parameters:
   129  // resourceGroupName - the name of the resource group within the user's subscription. The name is case
   130  // insensitive.
   131  // domainServiceName - the name of the domain service.
   132  func (client DomainServicesClient) Delete(ctx context.Context, resourceGroupName string, domainServiceName string) (result DomainServicesDeleteFuture, err error) {
   133  	if tracing.IsEnabled() {
   134  		ctx = tracing.StartSpan(ctx, fqdn+"/DomainServicesClient.Delete")
   135  		defer func() {
   136  			sc := -1
   137  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   138  				sc = result.FutureAPI.Response().StatusCode
   139  			}
   140  			tracing.EndSpan(ctx, sc, err)
   141  		}()
   142  	}
   143  	if err := validation.Validate([]validation.Validation{
   144  		{TargetValue: resourceGroupName,
   145  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   146  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   147  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   148  		return result, validation.NewError("aad.DomainServicesClient", "Delete", err.Error())
   149  	}
   150  
   151  	req, err := client.DeletePreparer(ctx, resourceGroupName, domainServiceName)
   152  	if err != nil {
   153  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "Delete", nil, "Failure preparing request")
   154  		return
   155  	}
   156  
   157  	result, err = client.DeleteSender(req)
   158  	if err != nil {
   159  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "Delete", result.Response(), "Failure sending request")
   160  		return
   161  	}
   162  
   163  	return
   164  }
   165  
   166  // DeletePreparer prepares the Delete request.
   167  func (client DomainServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, domainServiceName string) (*http.Request, error) {
   168  	pathParameters := map[string]interface{}{
   169  		"domainServiceName": autorest.Encode("path", domainServiceName),
   170  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   171  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   172  	}
   173  
   174  	const APIVersion = "2017-01-01"
   175  	queryParameters := map[string]interface{}{
   176  		"api-version": APIVersion,
   177  	}
   178  
   179  	preparer := autorest.CreatePreparer(
   180  		autorest.AsDelete(),
   181  		autorest.WithBaseURL(client.BaseURI),
   182  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AAD/domainServices/{domainServiceName}", pathParameters),
   183  		autorest.WithQueryParameters(queryParameters))
   184  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   185  }
   186  
   187  // DeleteSender sends the Delete request. The method will close the
   188  // http.Response Body if it receives an error.
   189  func (client DomainServicesClient) DeleteSender(req *http.Request) (future DomainServicesDeleteFuture, err error) {
   190  	var resp *http.Response
   191  	future.FutureAPI = &azure.Future{}
   192  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   193  	if err != nil {
   194  		return
   195  	}
   196  	var azf azure.Future
   197  	azf, err = azure.NewFutureFromResponse(resp)
   198  	future.FutureAPI = &azf
   199  	future.Result = future.result
   200  	return
   201  }
   202  
   203  // DeleteResponder handles the response to the Delete request. The method always
   204  // closes the http.Response Body.
   205  func (client DomainServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   206  	err = autorest.Respond(
   207  		resp,
   208  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   209  		autorest.ByClosing())
   210  	result.Response = resp
   211  	return
   212  }
   213  
   214  // Get the Get Domain Service operation retrieves a json representation of the Domain Service.
   215  // Parameters:
   216  // resourceGroupName - the name of the resource group within the user's subscription. The name is case
   217  // insensitive.
   218  // domainServiceName - the name of the domain service.
   219  func (client DomainServicesClient) Get(ctx context.Context, resourceGroupName string, domainServiceName string) (result DomainService, err error) {
   220  	if tracing.IsEnabled() {
   221  		ctx = tracing.StartSpan(ctx, fqdn+"/DomainServicesClient.Get")
   222  		defer func() {
   223  			sc := -1
   224  			if result.Response.Response != nil {
   225  				sc = result.Response.Response.StatusCode
   226  			}
   227  			tracing.EndSpan(ctx, sc, err)
   228  		}()
   229  	}
   230  	if err := validation.Validate([]validation.Validation{
   231  		{TargetValue: resourceGroupName,
   232  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   233  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   234  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   235  		return result, validation.NewError("aad.DomainServicesClient", "Get", err.Error())
   236  	}
   237  
   238  	req, err := client.GetPreparer(ctx, resourceGroupName, domainServiceName)
   239  	if err != nil {
   240  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "Get", nil, "Failure preparing request")
   241  		return
   242  	}
   243  
   244  	resp, err := client.GetSender(req)
   245  	if err != nil {
   246  		result.Response = autorest.Response{Response: resp}
   247  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "Get", resp, "Failure sending request")
   248  		return
   249  	}
   250  
   251  	result, err = client.GetResponder(resp)
   252  	if err != nil {
   253  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "Get", resp, "Failure responding to request")
   254  		return
   255  	}
   256  
   257  	return
   258  }
   259  
   260  // GetPreparer prepares the Get request.
   261  func (client DomainServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, domainServiceName string) (*http.Request, error) {
   262  	pathParameters := map[string]interface{}{
   263  		"domainServiceName": autorest.Encode("path", domainServiceName),
   264  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   265  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   266  	}
   267  
   268  	const APIVersion = "2017-01-01"
   269  	queryParameters := map[string]interface{}{
   270  		"api-version": APIVersion,
   271  	}
   272  
   273  	preparer := autorest.CreatePreparer(
   274  		autorest.AsGet(),
   275  		autorest.WithBaseURL(client.BaseURI),
   276  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AAD/domainServices/{domainServiceName}", 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.
   283  func (client DomainServicesClient) 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.
   289  func (client DomainServicesClient) GetResponder(resp *http.Response) (result DomainService, 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 the List Domain Services in Subscription operation lists all the domain services available under the given
   300  // subscription (and across all resource groups within that subscription).
   301  func (client DomainServicesClient) List(ctx context.Context) (result DomainServiceListResultPage, err error) {
   302  	if tracing.IsEnabled() {
   303  		ctx = tracing.StartSpan(ctx, fqdn+"/DomainServicesClient.List")
   304  		defer func() {
   305  			sc := -1
   306  			if result.dslr.Response.Response != nil {
   307  				sc = result.dslr.Response.Response.StatusCode
   308  			}
   309  			tracing.EndSpan(ctx, sc, err)
   310  		}()
   311  	}
   312  	result.fn = client.listNextResults
   313  	req, err := client.ListPreparer(ctx)
   314  	if err != nil {
   315  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "List", nil, "Failure preparing request")
   316  		return
   317  	}
   318  
   319  	resp, err := client.ListSender(req)
   320  	if err != nil {
   321  		result.dslr.Response = autorest.Response{Response: resp}
   322  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "List", resp, "Failure sending request")
   323  		return
   324  	}
   325  
   326  	result.dslr, err = client.ListResponder(resp)
   327  	if err != nil {
   328  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "List", resp, "Failure responding to request")
   329  		return
   330  	}
   331  	if result.dslr.hasNextLink() && result.dslr.IsEmpty() {
   332  		err = result.NextWithContext(ctx)
   333  		return
   334  	}
   335  
   336  	return
   337  }
   338  
   339  // ListPreparer prepares the List request.
   340  func (client DomainServicesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
   341  	pathParameters := map[string]interface{}{
   342  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   343  	}
   344  
   345  	const APIVersion = "2017-01-01"
   346  	queryParameters := map[string]interface{}{
   347  		"api-version": APIVersion,
   348  	}
   349  
   350  	preparer := autorest.CreatePreparer(
   351  		autorest.AsGet(),
   352  		autorest.WithBaseURL(client.BaseURI),
   353  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AAD/domainServices", pathParameters),
   354  		autorest.WithQueryParameters(queryParameters))
   355  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   356  }
   357  
   358  // ListSender sends the List request. The method will close the
   359  // http.Response Body if it receives an error.
   360  func (client DomainServicesClient) ListSender(req *http.Request) (*http.Response, error) {
   361  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   362  }
   363  
   364  // ListResponder handles the response to the List request. The method always
   365  // closes the http.Response Body.
   366  func (client DomainServicesClient) ListResponder(resp *http.Response) (result DomainServiceListResult, err error) {
   367  	err = autorest.Respond(
   368  		resp,
   369  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   370  		autorest.ByUnmarshallingJSON(&result),
   371  		autorest.ByClosing())
   372  	result.Response = autorest.Response{Response: resp}
   373  	return
   374  }
   375  
   376  // listNextResults retrieves the next set of results, if any.
   377  func (client DomainServicesClient) listNextResults(ctx context.Context, lastResults DomainServiceListResult) (result DomainServiceListResult, err error) {
   378  	req, err := lastResults.domainServiceListResultPreparer(ctx)
   379  	if err != nil {
   380  		return result, autorest.NewErrorWithError(err, "aad.DomainServicesClient", "listNextResults", nil, "Failure preparing next results request")
   381  	}
   382  	if req == nil {
   383  		return
   384  	}
   385  	resp, err := client.ListSender(req)
   386  	if err != nil {
   387  		result.Response = autorest.Response{Response: resp}
   388  		return result, autorest.NewErrorWithError(err, "aad.DomainServicesClient", "listNextResults", resp, "Failure sending next results request")
   389  	}
   390  	result, err = client.ListResponder(resp)
   391  	if err != nil {
   392  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "listNextResults", resp, "Failure responding to next results request")
   393  	}
   394  	return
   395  }
   396  
   397  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   398  func (client DomainServicesClient) ListComplete(ctx context.Context) (result DomainServiceListResultIterator, err error) {
   399  	if tracing.IsEnabled() {
   400  		ctx = tracing.StartSpan(ctx, fqdn+"/DomainServicesClient.List")
   401  		defer func() {
   402  			sc := -1
   403  			if result.Response().Response.Response != nil {
   404  				sc = result.page.Response().Response.Response.StatusCode
   405  			}
   406  			tracing.EndSpan(ctx, sc, err)
   407  		}()
   408  	}
   409  	result.page, err = client.List(ctx)
   410  	return
   411  }
   412  
   413  // ListByResourceGroup the List Domain Services in Resource Group operation lists all the domain services available
   414  // under the given resource group.
   415  // Parameters:
   416  // resourceGroupName - the name of the resource group within the user's subscription. The name is case
   417  // insensitive.
   418  func (client DomainServicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DomainServiceListResultPage, err error) {
   419  	if tracing.IsEnabled() {
   420  		ctx = tracing.StartSpan(ctx, fqdn+"/DomainServicesClient.ListByResourceGroup")
   421  		defer func() {
   422  			sc := -1
   423  			if result.dslr.Response.Response != nil {
   424  				sc = result.dslr.Response.Response.StatusCode
   425  			}
   426  			tracing.EndSpan(ctx, sc, err)
   427  		}()
   428  	}
   429  	if err := validation.Validate([]validation.Validation{
   430  		{TargetValue: resourceGroupName,
   431  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   432  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   433  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   434  		return result, validation.NewError("aad.DomainServicesClient", "ListByResourceGroup", err.Error())
   435  	}
   436  
   437  	result.fn = client.listByResourceGroupNextResults
   438  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
   439  	if err != nil {
   440  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "ListByResourceGroup", nil, "Failure preparing request")
   441  		return
   442  	}
   443  
   444  	resp, err := client.ListByResourceGroupSender(req)
   445  	if err != nil {
   446  		result.dslr.Response = autorest.Response{Response: resp}
   447  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "ListByResourceGroup", resp, "Failure sending request")
   448  		return
   449  	}
   450  
   451  	result.dslr, err = client.ListByResourceGroupResponder(resp)
   452  	if err != nil {
   453  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "ListByResourceGroup", resp, "Failure responding to request")
   454  		return
   455  	}
   456  	if result.dslr.hasNextLink() && result.dslr.IsEmpty() {
   457  		err = result.NextWithContext(ctx)
   458  		return
   459  	}
   460  
   461  	return
   462  }
   463  
   464  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   465  func (client DomainServicesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   466  	pathParameters := map[string]interface{}{
   467  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   468  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   469  	}
   470  
   471  	const APIVersion = "2017-01-01"
   472  	queryParameters := map[string]interface{}{
   473  		"api-version": APIVersion,
   474  	}
   475  
   476  	preparer := autorest.CreatePreparer(
   477  		autorest.AsGet(),
   478  		autorest.WithBaseURL(client.BaseURI),
   479  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AAD/domainServices", pathParameters),
   480  		autorest.WithQueryParameters(queryParameters))
   481  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   482  }
   483  
   484  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   485  // http.Response Body if it receives an error.
   486  func (client DomainServicesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   487  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   488  }
   489  
   490  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   491  // closes the http.Response Body.
   492  func (client DomainServicesClient) ListByResourceGroupResponder(resp *http.Response) (result DomainServiceListResult, err error) {
   493  	err = autorest.Respond(
   494  		resp,
   495  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   496  		autorest.ByUnmarshallingJSON(&result),
   497  		autorest.ByClosing())
   498  	result.Response = autorest.Response{Response: resp}
   499  	return
   500  }
   501  
   502  // listByResourceGroupNextResults retrieves the next set of results, if any.
   503  func (client DomainServicesClient) listByResourceGroupNextResults(ctx context.Context, lastResults DomainServiceListResult) (result DomainServiceListResult, err error) {
   504  	req, err := lastResults.domainServiceListResultPreparer(ctx)
   505  	if err != nil {
   506  		return result, autorest.NewErrorWithError(err, "aad.DomainServicesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
   507  	}
   508  	if req == nil {
   509  		return
   510  	}
   511  	resp, err := client.ListByResourceGroupSender(req)
   512  	if err != nil {
   513  		result.Response = autorest.Response{Response: resp}
   514  		return result, autorest.NewErrorWithError(err, "aad.DomainServicesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
   515  	}
   516  	result, err = client.ListByResourceGroupResponder(resp)
   517  	if err != nil {
   518  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
   519  	}
   520  	return
   521  }
   522  
   523  // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   524  func (client DomainServicesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DomainServiceListResultIterator, err error) {
   525  	if tracing.IsEnabled() {
   526  		ctx = tracing.StartSpan(ctx, fqdn+"/DomainServicesClient.ListByResourceGroup")
   527  		defer func() {
   528  			sc := -1
   529  			if result.Response().Response.Response != nil {
   530  				sc = result.page.Response().Response.Response.StatusCode
   531  			}
   532  			tracing.EndSpan(ctx, sc, err)
   533  		}()
   534  	}
   535  	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
   536  	return
   537  }
   538  
   539  // Update the Update Domain Service operation can be used to update the existing deployment. The update call only
   540  // supports the properties listed in the PATCH body.
   541  // Parameters:
   542  // resourceGroupName - the name of the resource group within the user's subscription. The name is case
   543  // insensitive.
   544  // domainServiceName - the name of the domain service.
   545  // domainService - properties supplied to the Update a Domain Service operation.
   546  func (client DomainServicesClient) Update(ctx context.Context, resourceGroupName string, domainServiceName string, domainService DomainService) (result DomainServicesUpdateFuture, err error) {
   547  	if tracing.IsEnabled() {
   548  		ctx = tracing.StartSpan(ctx, fqdn+"/DomainServicesClient.Update")
   549  		defer func() {
   550  			sc := -1
   551  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   552  				sc = result.FutureAPI.Response().StatusCode
   553  			}
   554  			tracing.EndSpan(ctx, sc, err)
   555  		}()
   556  	}
   557  	if err := validation.Validate([]validation.Validation{
   558  		{TargetValue: resourceGroupName,
   559  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   560  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   561  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
   562  		return result, validation.NewError("aad.DomainServicesClient", "Update", err.Error())
   563  	}
   564  
   565  	req, err := client.UpdatePreparer(ctx, resourceGroupName, domainServiceName, domainService)
   566  	if err != nil {
   567  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "Update", nil, "Failure preparing request")
   568  		return
   569  	}
   570  
   571  	result, err = client.UpdateSender(req)
   572  	if err != nil {
   573  		err = autorest.NewErrorWithError(err, "aad.DomainServicesClient", "Update", result.Response(), "Failure sending request")
   574  		return
   575  	}
   576  
   577  	return
   578  }
   579  
   580  // UpdatePreparer prepares the Update request.
   581  func (client DomainServicesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, domainServiceName string, domainService DomainService) (*http.Request, error) {
   582  	pathParameters := map[string]interface{}{
   583  		"domainServiceName": autorest.Encode("path", domainServiceName),
   584  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   585  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   586  	}
   587  
   588  	const APIVersion = "2017-01-01"
   589  	queryParameters := map[string]interface{}{
   590  		"api-version": APIVersion,
   591  	}
   592  
   593  	preparer := autorest.CreatePreparer(
   594  		autorest.AsContentType("application/json; charset=utf-8"),
   595  		autorest.AsPatch(),
   596  		autorest.WithBaseURL(client.BaseURI),
   597  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AAD/domainServices/{domainServiceName}", pathParameters),
   598  		autorest.WithJSON(domainService),
   599  		autorest.WithQueryParameters(queryParameters))
   600  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   601  }
   602  
   603  // UpdateSender sends the Update request. The method will close the
   604  // http.Response Body if it receives an error.
   605  func (client DomainServicesClient) UpdateSender(req *http.Request) (future DomainServicesUpdateFuture, err error) {
   606  	var resp *http.Response
   607  	future.FutureAPI = &azure.Future{}
   608  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   609  	if err != nil {
   610  		return
   611  	}
   612  	var azf azure.Future
   613  	azf, err = azure.NewFutureFromResponse(resp)
   614  	future.FutureAPI = &azf
   615  	future.Result = future.result
   616  	return
   617  }
   618  
   619  // UpdateResponder handles the response to the Update request. The method always
   620  // closes the http.Response Body.
   621  func (client DomainServicesClient) UpdateResponder(resp *http.Response) (result DomainService, err error) {
   622  	err = autorest.Respond(
   623  		resp,
   624  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   625  		autorest.ByUnmarshallingJSON(&result),
   626  		autorest.ByClosing())
   627  	result.Response = autorest.Response{Response: resp}
   628  	return
   629  }
   630  

View as plain text