...

Source file src/github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/insights/favorites.go

Documentation: github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/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  // FavoritesClient is the composite Swagger for Application Insights Management Client
    19  type FavoritesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewFavoritesClient creates an instance of the FavoritesClient client.
    24  func NewFavoritesClient(subscriptionID string) FavoritesClient {
    25  	return NewFavoritesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewFavoritesClientWithBaseURI creates an instance of the FavoritesClient client using a custom endpoint.  Use this
    29  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewFavoritesClientWithBaseURI(baseURI string, subscriptionID string) FavoritesClient {
    31  	return FavoritesClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // Add adds a new favorites to an Application Insights component.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group. The name is case insensitive.
    37  // resourceName - the name of the Application Insights component resource.
    38  // favoriteID - the Id of a specific favorite defined in the Application Insights component
    39  // favoriteProperties - properties that need to be specified to create a new favorite and add it to an
    40  // Application Insights component.
    41  func (client FavoritesClient) Add(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (result ApplicationInsightsComponentFavorite, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/FavoritesClient.Add")
    44  		defer func() {
    45  			sc := -1
    46  			if result.Response.Response != nil {
    47  				sc = result.Response.Response.StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	if err := validation.Validate([]validation.Validation{
    53  		{TargetValue: resourceGroupName,
    54  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
    55  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    56  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
    57  		{TargetValue: client.SubscriptionID,
    58  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
    59  		return result, validation.NewError("insights.FavoritesClient", "Add", err.Error())
    60  	}
    61  
    62  	req, err := client.AddPreparer(ctx, resourceGroupName, resourceName, favoriteID, favoriteProperties)
    63  	if err != nil {
    64  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Add", nil, "Failure preparing request")
    65  		return
    66  	}
    67  
    68  	resp, err := client.AddSender(req)
    69  	if err != nil {
    70  		result.Response = autorest.Response{Response: resp}
    71  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Add", resp, "Failure sending request")
    72  		return
    73  	}
    74  
    75  	result, err = client.AddResponder(resp)
    76  	if err != nil {
    77  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Add", resp, "Failure responding to request")
    78  		return
    79  	}
    80  
    81  	return
    82  }
    83  
    84  // AddPreparer prepares the Add request.
    85  func (client FavoritesClient) AddPreparer(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (*http.Request, error) {
    86  	pathParameters := map[string]interface{}{
    87  		"favoriteId":        autorest.Encode("path", favoriteID),
    88  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    89  		"resourceName":      autorest.Encode("path", resourceName),
    90  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    91  	}
    92  
    93  	const APIVersion = "2015-05-01"
    94  	queryParameters := map[string]interface{}{
    95  		"api-version": APIVersion,
    96  	}
    97  
    98  	favoriteProperties.FavoriteID = nil
    99  	favoriteProperties.TimeModified = nil
   100  	favoriteProperties.UserID = nil
   101  	preparer := autorest.CreatePreparer(
   102  		autorest.AsContentType("application/json; charset=utf-8"),
   103  		autorest.AsPut(),
   104  		autorest.WithBaseURL(client.BaseURI),
   105  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", pathParameters),
   106  		autorest.WithJSON(favoriteProperties),
   107  		autorest.WithQueryParameters(queryParameters))
   108  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   109  }
   110  
   111  // AddSender sends the Add request. The method will close the
   112  // http.Response Body if it receives an error.
   113  func (client FavoritesClient) AddSender(req *http.Request) (*http.Response, error) {
   114  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   115  }
   116  
   117  // AddResponder handles the response to the Add request. The method always
   118  // closes the http.Response Body.
   119  func (client FavoritesClient) AddResponder(resp *http.Response) (result ApplicationInsightsComponentFavorite, err error) {
   120  	err = autorest.Respond(
   121  		resp,
   122  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   123  		autorest.ByUnmarshallingJSON(&result),
   124  		autorest.ByClosing())
   125  	result.Response = autorest.Response{Response: resp}
   126  	return
   127  }
   128  
   129  // Delete remove a favorite that is associated to an Application Insights component.
   130  // Parameters:
   131  // resourceGroupName - the name of the resource group. The name is case insensitive.
   132  // resourceName - the name of the Application Insights component resource.
   133  // favoriteID - the Id of a specific favorite defined in the Application Insights component
   134  func (client FavoritesClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (result autorest.Response, err error) {
   135  	if tracing.IsEnabled() {
   136  		ctx = tracing.StartSpan(ctx, fqdn+"/FavoritesClient.Delete")
   137  		defer func() {
   138  			sc := -1
   139  			if result.Response != nil {
   140  				sc = result.Response.StatusCode
   141  			}
   142  			tracing.EndSpan(ctx, sc, err)
   143  		}()
   144  	}
   145  	if err := validation.Validate([]validation.Validation{
   146  		{TargetValue: resourceGroupName,
   147  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   148  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   149  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   150  		{TargetValue: client.SubscriptionID,
   151  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   152  		return result, validation.NewError("insights.FavoritesClient", "Delete", err.Error())
   153  	}
   154  
   155  	req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, favoriteID)
   156  	if err != nil {
   157  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Delete", nil, "Failure preparing request")
   158  		return
   159  	}
   160  
   161  	resp, err := client.DeleteSender(req)
   162  	if err != nil {
   163  		result.Response = resp
   164  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Delete", resp, "Failure sending request")
   165  		return
   166  	}
   167  
   168  	result, err = client.DeleteResponder(resp)
   169  	if err != nil {
   170  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Delete", resp, "Failure responding to request")
   171  		return
   172  	}
   173  
   174  	return
   175  }
   176  
   177  // DeletePreparer prepares the Delete request.
   178  func (client FavoritesClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (*http.Request, error) {
   179  	pathParameters := map[string]interface{}{
   180  		"favoriteId":        autorest.Encode("path", favoriteID),
   181  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   182  		"resourceName":      autorest.Encode("path", resourceName),
   183  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   184  	}
   185  
   186  	const APIVersion = "2015-05-01"
   187  	queryParameters := map[string]interface{}{
   188  		"api-version": APIVersion,
   189  	}
   190  
   191  	preparer := autorest.CreatePreparer(
   192  		autorest.AsDelete(),
   193  		autorest.WithBaseURL(client.BaseURI),
   194  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", pathParameters),
   195  		autorest.WithQueryParameters(queryParameters))
   196  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   197  }
   198  
   199  // DeleteSender sends the Delete request. The method will close the
   200  // http.Response Body if it receives an error.
   201  func (client FavoritesClient) DeleteSender(req *http.Request) (*http.Response, error) {
   202  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   203  }
   204  
   205  // DeleteResponder handles the response to the Delete request. The method always
   206  // closes the http.Response Body.
   207  func (client FavoritesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   208  	err = autorest.Respond(
   209  		resp,
   210  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   211  		autorest.ByClosing())
   212  	result.Response = resp
   213  	return
   214  }
   215  
   216  // Get get a single favorite by its FavoriteId, defined within an Application Insights component.
   217  // Parameters:
   218  // resourceGroupName - the name of the resource group. The name is case insensitive.
   219  // resourceName - the name of the Application Insights component resource.
   220  // favoriteID - the Id of a specific favorite defined in the Application Insights component
   221  func (client FavoritesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (result ApplicationInsightsComponentFavorite, err error) {
   222  	if tracing.IsEnabled() {
   223  		ctx = tracing.StartSpan(ctx, fqdn+"/FavoritesClient.Get")
   224  		defer func() {
   225  			sc := -1
   226  			if result.Response.Response != nil {
   227  				sc = result.Response.Response.StatusCode
   228  			}
   229  			tracing.EndSpan(ctx, sc, err)
   230  		}()
   231  	}
   232  	if err := validation.Validate([]validation.Validation{
   233  		{TargetValue: resourceGroupName,
   234  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   235  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   236  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   237  		{TargetValue: client.SubscriptionID,
   238  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   239  		return result, validation.NewError("insights.FavoritesClient", "Get", err.Error())
   240  	}
   241  
   242  	req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, favoriteID)
   243  	if err != nil {
   244  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Get", nil, "Failure preparing request")
   245  		return
   246  	}
   247  
   248  	resp, err := client.GetSender(req)
   249  	if err != nil {
   250  		result.Response = autorest.Response{Response: resp}
   251  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Get", resp, "Failure sending request")
   252  		return
   253  	}
   254  
   255  	result, err = client.GetResponder(resp)
   256  	if err != nil {
   257  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Get", resp, "Failure responding to request")
   258  		return
   259  	}
   260  
   261  	return
   262  }
   263  
   264  // GetPreparer prepares the Get request.
   265  func (client FavoritesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string) (*http.Request, error) {
   266  	pathParameters := map[string]interface{}{
   267  		"favoriteId":        autorest.Encode("path", favoriteID),
   268  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   269  		"resourceName":      autorest.Encode("path", resourceName),
   270  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   271  	}
   272  
   273  	const APIVersion = "2015-05-01"
   274  	queryParameters := map[string]interface{}{
   275  		"api-version": APIVersion,
   276  	}
   277  
   278  	preparer := autorest.CreatePreparer(
   279  		autorest.AsGet(),
   280  		autorest.WithBaseURL(client.BaseURI),
   281  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", pathParameters),
   282  		autorest.WithQueryParameters(queryParameters))
   283  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   284  }
   285  
   286  // GetSender sends the Get request. The method will close the
   287  // http.Response Body if it receives an error.
   288  func (client FavoritesClient) GetSender(req *http.Request) (*http.Response, error) {
   289  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   290  }
   291  
   292  // GetResponder handles the response to the Get request. The method always
   293  // closes the http.Response Body.
   294  func (client FavoritesClient) GetResponder(resp *http.Response) (result ApplicationInsightsComponentFavorite, err error) {
   295  	err = autorest.Respond(
   296  		resp,
   297  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   298  		autorest.ByUnmarshallingJSON(&result),
   299  		autorest.ByClosing())
   300  	result.Response = autorest.Response{Response: resp}
   301  	return
   302  }
   303  
   304  // List gets a list of favorites defined within an Application Insights component.
   305  // Parameters:
   306  // resourceGroupName - the name of the resource group. The name is case insensitive.
   307  // resourceName - the name of the Application Insights component resource.
   308  // favoriteType - the type of favorite. Value can be either shared or user.
   309  // sourceType - source type of favorite to return. When left out, the source type defaults to 'other' (not
   310  // present in this enum).
   311  // canFetchContent - flag indicating whether or not to return the full content for each applicable favorite. If
   312  // false, only return summary content for favorites.
   313  // tags - tags that must be present on each favorite returned.
   314  func (client FavoritesClient) List(ctx context.Context, resourceGroupName string, resourceName string, favoriteType FavoriteType, sourceType FavoriteSourceType, canFetchContent *bool, tags []string) (result ListApplicationInsightsComponentFavorite, err error) {
   315  	if tracing.IsEnabled() {
   316  		ctx = tracing.StartSpan(ctx, fqdn+"/FavoritesClient.List")
   317  		defer func() {
   318  			sc := -1
   319  			if result.Response.Response != nil {
   320  				sc = result.Response.Response.StatusCode
   321  			}
   322  			tracing.EndSpan(ctx, sc, err)
   323  		}()
   324  	}
   325  	if err := validation.Validate([]validation.Validation{
   326  		{TargetValue: resourceGroupName,
   327  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   328  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   329  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   330  		{TargetValue: client.SubscriptionID,
   331  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   332  		return result, validation.NewError("insights.FavoritesClient", "List", err.Error())
   333  	}
   334  
   335  	req, err := client.ListPreparer(ctx, resourceGroupName, resourceName, favoriteType, sourceType, canFetchContent, tags)
   336  	if err != nil {
   337  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "List", nil, "Failure preparing request")
   338  		return
   339  	}
   340  
   341  	resp, err := client.ListSender(req)
   342  	if err != nil {
   343  		result.Response = autorest.Response{Response: resp}
   344  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "List", resp, "Failure sending request")
   345  		return
   346  	}
   347  
   348  	result, err = client.ListResponder(resp)
   349  	if err != nil {
   350  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "List", resp, "Failure responding to request")
   351  		return
   352  	}
   353  
   354  	return
   355  }
   356  
   357  // ListPreparer prepares the List request.
   358  func (client FavoritesClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string, favoriteType FavoriteType, sourceType FavoriteSourceType, canFetchContent *bool, tags []string) (*http.Request, error) {
   359  	pathParameters := map[string]interface{}{
   360  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   361  		"resourceName":      autorest.Encode("path", resourceName),
   362  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   363  	}
   364  
   365  	const APIVersion = "2015-05-01"
   366  	queryParameters := map[string]interface{}{
   367  		"api-version": APIVersion,
   368  	}
   369  	if len(string(favoriteType)) > 0 {
   370  		queryParameters["favoriteType"] = autorest.Encode("query", favoriteType)
   371  	} else {
   372  		queryParameters["favoriteType"] = autorest.Encode("query", "shared")
   373  	}
   374  	if len(string(sourceType)) > 0 {
   375  		queryParameters["sourceType"] = autorest.Encode("query", sourceType)
   376  	}
   377  	if canFetchContent != nil {
   378  		queryParameters["canFetchContent"] = autorest.Encode("query", *canFetchContent)
   379  	}
   380  	if tags != nil && len(tags) > 0 {
   381  		queryParameters["tags"] = autorest.Encode("query", tags, ",")
   382  	}
   383  
   384  	preparer := autorest.CreatePreparer(
   385  		autorest.AsGet(),
   386  		autorest.WithBaseURL(client.BaseURI),
   387  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites", pathParameters),
   388  		autorest.WithQueryParameters(queryParameters))
   389  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   390  }
   391  
   392  // ListSender sends the List request. The method will close the
   393  // http.Response Body if it receives an error.
   394  func (client FavoritesClient) ListSender(req *http.Request) (*http.Response, error) {
   395  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   396  }
   397  
   398  // ListResponder handles the response to the List request. The method always
   399  // closes the http.Response Body.
   400  func (client FavoritesClient) ListResponder(resp *http.Response) (result ListApplicationInsightsComponentFavorite, err error) {
   401  	err = autorest.Respond(
   402  		resp,
   403  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   404  		autorest.ByUnmarshallingJSON(&result.Value),
   405  		autorest.ByClosing())
   406  	result.Response = autorest.Response{Response: resp}
   407  	return
   408  }
   409  
   410  // Update updates a favorite that has already been added to an Application Insights component.
   411  // Parameters:
   412  // resourceGroupName - the name of the resource group. The name is case insensitive.
   413  // resourceName - the name of the Application Insights component resource.
   414  // favoriteID - the Id of a specific favorite defined in the Application Insights component
   415  // favoriteProperties - properties that need to be specified to update the existing favorite.
   416  func (client FavoritesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (result ApplicationInsightsComponentFavorite, err error) {
   417  	if tracing.IsEnabled() {
   418  		ctx = tracing.StartSpan(ctx, fqdn+"/FavoritesClient.Update")
   419  		defer func() {
   420  			sc := -1
   421  			if result.Response.Response != nil {
   422  				sc = result.Response.Response.StatusCode
   423  			}
   424  			tracing.EndSpan(ctx, sc, err)
   425  		}()
   426  	}
   427  	if err := validation.Validate([]validation.Validation{
   428  		{TargetValue: resourceGroupName,
   429  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   430  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   431  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
   432  		{TargetValue: client.SubscriptionID,
   433  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   434  		return result, validation.NewError("insights.FavoritesClient", "Update", err.Error())
   435  	}
   436  
   437  	req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, favoriteID, favoriteProperties)
   438  	if err != nil {
   439  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Update", nil, "Failure preparing request")
   440  		return
   441  	}
   442  
   443  	resp, err := client.UpdateSender(req)
   444  	if err != nil {
   445  		result.Response = autorest.Response{Response: resp}
   446  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Update", resp, "Failure sending request")
   447  		return
   448  	}
   449  
   450  	result, err = client.UpdateResponder(resp)
   451  	if err != nil {
   452  		err = autorest.NewErrorWithError(err, "insights.FavoritesClient", "Update", resp, "Failure responding to request")
   453  		return
   454  	}
   455  
   456  	return
   457  }
   458  
   459  // UpdatePreparer prepares the Update request.
   460  func (client FavoritesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, favoriteID string, favoriteProperties ApplicationInsightsComponentFavorite) (*http.Request, error) {
   461  	pathParameters := map[string]interface{}{
   462  		"favoriteId":        autorest.Encode("path", favoriteID),
   463  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   464  		"resourceName":      autorest.Encode("path", resourceName),
   465  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   466  	}
   467  
   468  	const APIVersion = "2015-05-01"
   469  	queryParameters := map[string]interface{}{
   470  		"api-version": APIVersion,
   471  	}
   472  
   473  	favoriteProperties.FavoriteID = nil
   474  	favoriteProperties.TimeModified = nil
   475  	favoriteProperties.UserID = nil
   476  	preparer := autorest.CreatePreparer(
   477  		autorest.AsContentType("application/json; charset=utf-8"),
   478  		autorest.AsPatch(),
   479  		autorest.WithBaseURL(client.BaseURI),
   480  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/components/{resourceName}/favorites/{favoriteId}", pathParameters),
   481  		autorest.WithJSON(favoriteProperties),
   482  		autorest.WithQueryParameters(queryParameters))
   483  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   484  }
   485  
   486  // UpdateSender sends the Update request. The method will close the
   487  // http.Response Body if it receives an error.
   488  func (client FavoritesClient) UpdateSender(req *http.Request) (*http.Response, error) {
   489  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   490  }
   491  
   492  // UpdateResponder handles the response to the Update request. The method always
   493  // closes the http.Response Body.
   494  func (client FavoritesClient) UpdateResponder(resp *http.Response) (result ApplicationInsightsComponentFavorite, err error) {
   495  	err = autorest.Respond(
   496  		resp,
   497  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   498  		autorest.ByUnmarshallingJSON(&result),
   499  		autorest.ByClosing())
   500  	result.Response = autorest.Response{Response: resp}
   501  	return
   502  }
   503  

View as plain text