...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-07-01-preview/insights/privatelinkscopes.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-07-01-preview/insights

     1  package insights
     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  // PrivateLinkScopesClient is the monitor Management Client
    19  type PrivateLinkScopesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewPrivateLinkScopesClient creates an instance of the PrivateLinkScopesClient client.
    24  func NewPrivateLinkScopesClient(subscriptionID string) PrivateLinkScopesClient {
    25  	return NewPrivateLinkScopesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewPrivateLinkScopesClientWithBaseURI creates an instance of the PrivateLinkScopesClient client using a custom
    29  // endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
    30  // stack).
    31  func NewPrivateLinkScopesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkScopesClient {
    32  	return PrivateLinkScopesClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // CreateOrUpdate creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different value for
    36  // InstrumentationKey nor AppId in the Put operation.
    37  // Parameters:
    38  // resourceGroupName - the name of the resource group. The name is case insensitive.
    39  // scopeName - the name of the Azure Monitor PrivateLinkScope resource.
    40  // azureMonitorPrivateLinkScopePayload - properties that need to be specified to create or update a Azure
    41  // Monitor PrivateLinkScope.
    42  func (client PrivateLinkScopesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, azureMonitorPrivateLinkScopePayload AzureMonitorPrivateLinkScope) (result AzureMonitorPrivateLinkScope, err error) {
    43  	if tracing.IsEnabled() {
    44  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.CreateOrUpdate")
    45  		defer func() {
    46  			sc := -1
    47  			if result.Response.Response != nil {
    48  				sc = result.Response.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  		{TargetValue: client.SubscriptionID,
    58  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    59  		{TargetValue: azureMonitorPrivateLinkScopePayload,
    60  			Constraints: []validation.Constraint{{Target: "azureMonitorPrivateLinkScopePayload.AzureMonitorPrivateLinkScopeProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
    61  		return result, validation.NewError("insights.PrivateLinkScopesClient", "CreateOrUpdate", err.Error())
    62  	}
    63  
    64  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, scopeName, azureMonitorPrivateLinkScopePayload)
    65  	if err != nil {
    66  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "CreateOrUpdate", nil, "Failure preparing request")
    67  		return
    68  	}
    69  
    70  	resp, err := client.CreateOrUpdateSender(req)
    71  	if err != nil {
    72  		result.Response = autorest.Response{Response: resp}
    73  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "CreateOrUpdate", resp, "Failure sending request")
    74  		return
    75  	}
    76  
    77  	result, err = client.CreateOrUpdateResponder(resp)
    78  	if err != nil {
    79  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "CreateOrUpdate", resp, "Failure responding to request")
    80  		return
    81  	}
    82  
    83  	return
    84  }
    85  
    86  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    87  func (client PrivateLinkScopesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, scopeName string, azureMonitorPrivateLinkScopePayload AzureMonitorPrivateLinkScope) (*http.Request, error) {
    88  	pathParameters := map[string]interface{}{
    89  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    90  		"scopeName":         autorest.Encode("path", scopeName),
    91  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    92  	}
    93  
    94  	const APIVersion = "2019-10-17-preview"
    95  	queryParameters := map[string]interface{}{
    96  		"api-version": APIVersion,
    97  	}
    98  
    99  	preparer := autorest.CreatePreparer(
   100  		autorest.AsContentType("application/json; charset=utf-8"),
   101  		autorest.AsPut(),
   102  		autorest.WithBaseURL(client.BaseURI),
   103  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", pathParameters),
   104  		autorest.WithJSON(azureMonitorPrivateLinkScopePayload),
   105  		autorest.WithQueryParameters(queryParameters))
   106  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   107  }
   108  
   109  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   110  // http.Response Body if it receives an error.
   111  func (client PrivateLinkScopesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
   112  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   113  }
   114  
   115  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   116  // closes the http.Response Body.
   117  func (client PrivateLinkScopesClient) CreateOrUpdateResponder(resp *http.Response) (result AzureMonitorPrivateLinkScope, err error) {
   118  	err = autorest.Respond(
   119  		resp,
   120  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   121  		autorest.ByUnmarshallingJSON(&result),
   122  		autorest.ByClosing())
   123  	result.Response = autorest.Response{Response: resp}
   124  	return
   125  }
   126  
   127  // Delete deletes a Azure Monitor PrivateLinkScope.
   128  // Parameters:
   129  // resourceGroupName - the name of the resource group. The name is case insensitive.
   130  // scopeName - the name of the Azure Monitor PrivateLinkScope resource.
   131  func (client PrivateLinkScopesClient) Delete(ctx context.Context, resourceGroupName string, scopeName string) (result PrivateLinkScopesDeleteFuture, err error) {
   132  	if tracing.IsEnabled() {
   133  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.Delete")
   134  		defer func() {
   135  			sc := -1
   136  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   137  				sc = result.FutureAPI.Response().StatusCode
   138  			}
   139  			tracing.EndSpan(ctx, sc, err)
   140  		}()
   141  	}
   142  	if err := validation.Validate([]validation.Validation{
   143  		{TargetValue: resourceGroupName,
   144  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   145  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   146  		{TargetValue: client.SubscriptionID,
   147  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   148  		return result, validation.NewError("insights.PrivateLinkScopesClient", "Delete", err.Error())
   149  	}
   150  
   151  	req, err := client.DeletePreparer(ctx, resourceGroupName, scopeName)
   152  	if err != nil {
   153  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Delete", nil, "Failure preparing request")
   154  		return
   155  	}
   156  
   157  	result, err = client.DeleteSender(req)
   158  	if err != nil {
   159  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Delete", result.Response(), "Failure sending request")
   160  		return
   161  	}
   162  
   163  	return
   164  }
   165  
   166  // DeletePreparer prepares the Delete request.
   167  func (client PrivateLinkScopesClient) DeletePreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) {
   168  	pathParameters := map[string]interface{}{
   169  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   170  		"scopeName":         autorest.Encode("path", scopeName),
   171  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   172  	}
   173  
   174  	const APIVersion = "2019-10-17-preview"
   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.insights/privateLinkScopes/{scopeName}", 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 PrivateLinkScopesClient) DeleteSender(req *http.Request) (future PrivateLinkScopesDeleteFuture, 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 PrivateLinkScopesClient) 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 returns a Azure Monitor PrivateLinkScope.
   215  // Parameters:
   216  // resourceGroupName - the name of the resource group. The name is case insensitive.
   217  // scopeName - the name of the Azure Monitor PrivateLinkScope resource.
   218  func (client PrivateLinkScopesClient) Get(ctx context.Context, resourceGroupName string, scopeName string) (result AzureMonitorPrivateLinkScope, err error) {
   219  	if tracing.IsEnabled() {
   220  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.Get")
   221  		defer func() {
   222  			sc := -1
   223  			if result.Response.Response != nil {
   224  				sc = result.Response.Response.StatusCode
   225  			}
   226  			tracing.EndSpan(ctx, sc, err)
   227  		}()
   228  	}
   229  	if err := validation.Validate([]validation.Validation{
   230  		{TargetValue: resourceGroupName,
   231  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   232  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   233  		{TargetValue: client.SubscriptionID,
   234  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   235  		return result, validation.NewError("insights.PrivateLinkScopesClient", "Get", err.Error())
   236  	}
   237  
   238  	req, err := client.GetPreparer(ctx, resourceGroupName, scopeName)
   239  	if err != nil {
   240  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "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, "insights.PrivateLinkScopesClient", "Get", resp, "Failure sending request")
   248  		return
   249  	}
   250  
   251  	result, err = client.GetResponder(resp)
   252  	if err != nil {
   253  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Get", resp, "Failure responding to request")
   254  		return
   255  	}
   256  
   257  	return
   258  }
   259  
   260  // GetPreparer prepares the Get request.
   261  func (client PrivateLinkScopesClient) GetPreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) {
   262  	pathParameters := map[string]interface{}{
   263  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   264  		"scopeName":         autorest.Encode("path", scopeName),
   265  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   266  	}
   267  
   268  	const APIVersion = "2019-10-17-preview"
   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.insights/privateLinkScopes/{scopeName}", 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 PrivateLinkScopesClient) 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 PrivateLinkScopesClient) GetResponder(resp *http.Response) (result AzureMonitorPrivateLinkScope, 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 gets a list of all Azure Monitor PrivateLinkScopes within a subscription.
   300  func (client PrivateLinkScopesClient) List(ctx context.Context) (result AzureMonitorPrivateLinkScopeListResultPage, err error) {
   301  	if tracing.IsEnabled() {
   302  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.List")
   303  		defer func() {
   304  			sc := -1
   305  			if result.amplslr.Response.Response != nil {
   306  				sc = result.amplslr.Response.Response.StatusCode
   307  			}
   308  			tracing.EndSpan(ctx, sc, err)
   309  		}()
   310  	}
   311  	if err := validation.Validate([]validation.Validation{
   312  		{TargetValue: client.SubscriptionID,
   313  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   314  		return result, validation.NewError("insights.PrivateLinkScopesClient", "List", err.Error())
   315  	}
   316  
   317  	result.fn = client.listNextResults
   318  	req, err := client.ListPreparer(ctx)
   319  	if err != nil {
   320  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "List", nil, "Failure preparing request")
   321  		return
   322  	}
   323  
   324  	resp, err := client.ListSender(req)
   325  	if err != nil {
   326  		result.amplslr.Response = autorest.Response{Response: resp}
   327  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "List", resp, "Failure sending request")
   328  		return
   329  	}
   330  
   331  	result.amplslr, err = client.ListResponder(resp)
   332  	if err != nil {
   333  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "List", resp, "Failure responding to request")
   334  		return
   335  	}
   336  	if result.amplslr.hasNextLink() && result.amplslr.IsEmpty() {
   337  		err = result.NextWithContext(ctx)
   338  		return
   339  	}
   340  
   341  	return
   342  }
   343  
   344  // ListPreparer prepares the List request.
   345  func (client PrivateLinkScopesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
   346  	pathParameters := map[string]interface{}{
   347  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   348  	}
   349  
   350  	const APIVersion = "2019-10-17-preview"
   351  	queryParameters := map[string]interface{}{
   352  		"api-version": APIVersion,
   353  	}
   354  
   355  	preparer := autorest.CreatePreparer(
   356  		autorest.AsGet(),
   357  		autorest.WithBaseURL(client.BaseURI),
   358  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes", pathParameters),
   359  		autorest.WithQueryParameters(queryParameters))
   360  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   361  }
   362  
   363  // ListSender sends the List request. The method will close the
   364  // http.Response Body if it receives an error.
   365  func (client PrivateLinkScopesClient) ListSender(req *http.Request) (*http.Response, error) {
   366  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   367  }
   368  
   369  // ListResponder handles the response to the List request. The method always
   370  // closes the http.Response Body.
   371  func (client PrivateLinkScopesClient) ListResponder(resp *http.Response) (result AzureMonitorPrivateLinkScopeListResult, err error) {
   372  	err = autorest.Respond(
   373  		resp,
   374  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   375  		autorest.ByUnmarshallingJSON(&result),
   376  		autorest.ByClosing())
   377  	result.Response = autorest.Response{Response: resp}
   378  	return
   379  }
   380  
   381  // listNextResults retrieves the next set of results, if any.
   382  func (client PrivateLinkScopesClient) listNextResults(ctx context.Context, lastResults AzureMonitorPrivateLinkScopeListResult) (result AzureMonitorPrivateLinkScopeListResult, err error) {
   383  	req, err := lastResults.azureMonitorPrivateLinkScopeListResultPreparer(ctx)
   384  	if err != nil {
   385  		return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listNextResults", nil, "Failure preparing next results request")
   386  	}
   387  	if req == nil {
   388  		return
   389  	}
   390  	resp, err := client.ListSender(req)
   391  	if err != nil {
   392  		result.Response = autorest.Response{Response: resp}
   393  		return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listNextResults", resp, "Failure sending next results request")
   394  	}
   395  	result, err = client.ListResponder(resp)
   396  	if err != nil {
   397  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listNextResults", resp, "Failure responding to next results request")
   398  	}
   399  	return
   400  }
   401  
   402  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   403  func (client PrivateLinkScopesClient) ListComplete(ctx context.Context) (result AzureMonitorPrivateLinkScopeListResultIterator, err error) {
   404  	if tracing.IsEnabled() {
   405  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.List")
   406  		defer func() {
   407  			sc := -1
   408  			if result.Response().Response.Response != nil {
   409  				sc = result.page.Response().Response.Response.StatusCode
   410  			}
   411  			tracing.EndSpan(ctx, sc, err)
   412  		}()
   413  	}
   414  	result.page, err = client.List(ctx)
   415  	return
   416  }
   417  
   418  // ListByResourceGroup gets a list of Azure Monitor PrivateLinkScopes within a resource group.
   419  // Parameters:
   420  // resourceGroupName - the name of the resource group. The name is case insensitive.
   421  func (client PrivateLinkScopesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AzureMonitorPrivateLinkScopeListResultPage, err error) {
   422  	if tracing.IsEnabled() {
   423  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.ListByResourceGroup")
   424  		defer func() {
   425  			sc := -1
   426  			if result.amplslr.Response.Response != nil {
   427  				sc = result.amplslr.Response.Response.StatusCode
   428  			}
   429  			tracing.EndSpan(ctx, sc, err)
   430  		}()
   431  	}
   432  	if err := validation.Validate([]validation.Validation{
   433  		{TargetValue: resourceGroupName,
   434  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   435  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   436  		{TargetValue: client.SubscriptionID,
   437  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   438  		return result, validation.NewError("insights.PrivateLinkScopesClient", "ListByResourceGroup", err.Error())
   439  	}
   440  
   441  	result.fn = client.listByResourceGroupNextResults
   442  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
   443  	if err != nil {
   444  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "ListByResourceGroup", nil, "Failure preparing request")
   445  		return
   446  	}
   447  
   448  	resp, err := client.ListByResourceGroupSender(req)
   449  	if err != nil {
   450  		result.amplslr.Response = autorest.Response{Response: resp}
   451  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "ListByResourceGroup", resp, "Failure sending request")
   452  		return
   453  	}
   454  
   455  	result.amplslr, err = client.ListByResourceGroupResponder(resp)
   456  	if err != nil {
   457  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "ListByResourceGroup", resp, "Failure responding to request")
   458  		return
   459  	}
   460  	if result.amplslr.hasNextLink() && result.amplslr.IsEmpty() {
   461  		err = result.NextWithContext(ctx)
   462  		return
   463  	}
   464  
   465  	return
   466  }
   467  
   468  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   469  func (client PrivateLinkScopesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   470  	pathParameters := map[string]interface{}{
   471  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   472  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   473  	}
   474  
   475  	const APIVersion = "2019-10-17-preview"
   476  	queryParameters := map[string]interface{}{
   477  		"api-version": APIVersion,
   478  	}
   479  
   480  	preparer := autorest.CreatePreparer(
   481  		autorest.AsGet(),
   482  		autorest.WithBaseURL(client.BaseURI),
   483  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes", pathParameters),
   484  		autorest.WithQueryParameters(queryParameters))
   485  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   486  }
   487  
   488  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   489  // http.Response Body if it receives an error.
   490  func (client PrivateLinkScopesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   491  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   492  }
   493  
   494  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   495  // closes the http.Response Body.
   496  func (client PrivateLinkScopesClient) ListByResourceGroupResponder(resp *http.Response) (result AzureMonitorPrivateLinkScopeListResult, err error) {
   497  	err = autorest.Respond(
   498  		resp,
   499  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   500  		autorest.ByUnmarshallingJSON(&result),
   501  		autorest.ByClosing())
   502  	result.Response = autorest.Response{Response: resp}
   503  	return
   504  }
   505  
   506  // listByResourceGroupNextResults retrieves the next set of results, if any.
   507  func (client PrivateLinkScopesClient) listByResourceGroupNextResults(ctx context.Context, lastResults AzureMonitorPrivateLinkScopeListResult) (result AzureMonitorPrivateLinkScopeListResult, err error) {
   508  	req, err := lastResults.azureMonitorPrivateLinkScopeListResultPreparer(ctx)
   509  	if err != nil {
   510  		return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
   511  	}
   512  	if req == nil {
   513  		return
   514  	}
   515  	resp, err := client.ListByResourceGroupSender(req)
   516  	if err != nil {
   517  		result.Response = autorest.Response{Response: resp}
   518  		return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
   519  	}
   520  	result, err = client.ListByResourceGroupResponder(resp)
   521  	if err != nil {
   522  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
   523  	}
   524  	return
   525  }
   526  
   527  // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   528  func (client PrivateLinkScopesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AzureMonitorPrivateLinkScopeListResultIterator, err error) {
   529  	if tracing.IsEnabled() {
   530  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.ListByResourceGroup")
   531  		defer func() {
   532  			sc := -1
   533  			if result.Response().Response.Response != nil {
   534  				sc = result.page.Response().Response.Response.StatusCode
   535  			}
   536  			tracing.EndSpan(ctx, sc, err)
   537  		}()
   538  	}
   539  	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
   540  	return
   541  }
   542  
   543  // UpdateTags updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate method.
   544  // Parameters:
   545  // resourceGroupName - the name of the resource group. The name is case insensitive.
   546  // scopeName - the name of the Azure Monitor PrivateLinkScope resource.
   547  // privateLinkScopeTags - updated tag information to set into the PrivateLinkScope instance.
   548  func (client PrivateLinkScopesClient) UpdateTags(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags TagsResource) (result AzureMonitorPrivateLinkScope, err error) {
   549  	if tracing.IsEnabled() {
   550  		ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.UpdateTags")
   551  		defer func() {
   552  			sc := -1
   553  			if result.Response.Response != nil {
   554  				sc = result.Response.Response.StatusCode
   555  			}
   556  			tracing.EndSpan(ctx, sc, err)
   557  		}()
   558  	}
   559  	if err := validation.Validate([]validation.Validation{
   560  		{TargetValue: resourceGroupName,
   561  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   562  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   563  		{TargetValue: client.SubscriptionID,
   564  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   565  		return result, validation.NewError("insights.PrivateLinkScopesClient", "UpdateTags", err.Error())
   566  	}
   567  
   568  	req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, scopeName, privateLinkScopeTags)
   569  	if err != nil {
   570  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "UpdateTags", nil, "Failure preparing request")
   571  		return
   572  	}
   573  
   574  	resp, err := client.UpdateTagsSender(req)
   575  	if err != nil {
   576  		result.Response = autorest.Response{Response: resp}
   577  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "UpdateTags", resp, "Failure sending request")
   578  		return
   579  	}
   580  
   581  	result, err = client.UpdateTagsResponder(resp)
   582  	if err != nil {
   583  		err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "UpdateTags", resp, "Failure responding to request")
   584  		return
   585  	}
   586  
   587  	return
   588  }
   589  
   590  // UpdateTagsPreparer prepares the UpdateTags request.
   591  func (client PrivateLinkScopesClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags TagsResource) (*http.Request, error) {
   592  	pathParameters := map[string]interface{}{
   593  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   594  		"scopeName":         autorest.Encode("path", scopeName),
   595  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   596  	}
   597  
   598  	const APIVersion = "2019-10-17-preview"
   599  	queryParameters := map[string]interface{}{
   600  		"api-version": APIVersion,
   601  	}
   602  
   603  	preparer := autorest.CreatePreparer(
   604  		autorest.AsContentType("application/json; charset=utf-8"),
   605  		autorest.AsPatch(),
   606  		autorest.WithBaseURL(client.BaseURI),
   607  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", pathParameters),
   608  		autorest.WithJSON(privateLinkScopeTags),
   609  		autorest.WithQueryParameters(queryParameters))
   610  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   611  }
   612  
   613  // UpdateTagsSender sends the UpdateTags request. The method will close the
   614  // http.Response Body if it receives an error.
   615  func (client PrivateLinkScopesClient) UpdateTagsSender(req *http.Request) (*http.Response, error) {
   616  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   617  }
   618  
   619  // UpdateTagsResponder handles the response to the UpdateTags request. The method always
   620  // closes the http.Response Body.
   621  func (client PrivateLinkScopesClient) UpdateTagsResponder(resp *http.Response) (result AzureMonitorPrivateLinkScope, err error) {
   622  	err = autorest.Respond(
   623  		resp,
   624  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   625  		autorest.ByUnmarshallingJSON(&result),
   626  		autorest.ByClosing())
   627  	result.Response = autorest.Response{Response: resp}
   628  	return
   629  }
   630  

View as plain text