...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2022-10-01-preview/insights/actiongroups.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2022-10-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  // ActionGroupsClient is the monitor Management Client
    19  type ActionGroupsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewActionGroupsClient creates an instance of the ActionGroupsClient client.
    24  func NewActionGroupsClient(subscriptionID string) ActionGroupsClient {
    25  	return NewActionGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewActionGroupsClientWithBaseURI creates an instance of the ActionGroupsClient client using a custom endpoint.  Use
    29  // this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewActionGroupsClientWithBaseURI(baseURI string, subscriptionID string) ActionGroupsClient {
    31  	return ActionGroupsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // CreateNotificationsAtActionGroupResourceLevel send test notifications to a set of provided receivers
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group. The name is case insensitive.
    37  // actionGroupName - the name of the action group.
    38  // notificationRequest - the notification request body which includes the contact details
    39  func (client ActionGroupsClient) CreateNotificationsAtActionGroupResourceLevel(ctx context.Context, resourceGroupName string, actionGroupName string, notificationRequest NotificationRequestBody) (result ActionGroupsCreateNotificationsAtActionGroupResourceLevelFuture, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.CreateNotificationsAtActionGroupResourceLevel")
    42  		defer func() {
    43  			sc := -1
    44  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    45  				sc = result.FutureAPI.Response().StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	if err := validation.Validate([]validation.Validation{
    51  		{TargetValue: client.SubscriptionID,
    52  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
    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  		{TargetValue: notificationRequest,
    57  			Constraints: []validation.Constraint{{Target: "notificationRequest.AlertType", Name: validation.Null, Rule: true,
    58  				Chain: []validation.Constraint{{Target: "notificationRequest.AlertType", Name: validation.MaxLength, Rule: 30, Chain: nil}}}}}}); err != nil {
    59  		return result, validation.NewError("insights.ActionGroupsClient", "CreateNotificationsAtActionGroupResourceLevel", err.Error())
    60  	}
    61  
    62  	req, err := client.CreateNotificationsAtActionGroupResourceLevelPreparer(ctx, resourceGroupName, actionGroupName, notificationRequest)
    63  	if err != nil {
    64  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateNotificationsAtActionGroupResourceLevel", nil, "Failure preparing request")
    65  		return
    66  	}
    67  
    68  	result, err = client.CreateNotificationsAtActionGroupResourceLevelSender(req)
    69  	if err != nil {
    70  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateNotificationsAtActionGroupResourceLevel", result.Response(), "Failure sending request")
    71  		return
    72  	}
    73  
    74  	return
    75  }
    76  
    77  // CreateNotificationsAtActionGroupResourceLevelPreparer prepares the CreateNotificationsAtActionGroupResourceLevel request.
    78  func (client ActionGroupsClient) CreateNotificationsAtActionGroupResourceLevelPreparer(ctx context.Context, resourceGroupName string, actionGroupName string, notificationRequest NotificationRequestBody) (*http.Request, error) {
    79  	pathParameters := map[string]interface{}{
    80  		"actionGroupName":   autorest.Encode("path", actionGroupName),
    81  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    82  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    83  	}
    84  
    85  	const APIVersion = "2022-06-01"
    86  	queryParameters := map[string]interface{}{
    87  		"api-version": APIVersion,
    88  	}
    89  
    90  	preparer := autorest.CreatePreparer(
    91  		autorest.AsContentType("application/json; charset=utf-8"),
    92  		autorest.AsPost(),
    93  		autorest.WithBaseURL(client.BaseURI),
    94  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications", pathParameters),
    95  		autorest.WithJSON(notificationRequest),
    96  		autorest.WithQueryParameters(queryParameters))
    97  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    98  }
    99  
   100  // CreateNotificationsAtActionGroupResourceLevelSender sends the CreateNotificationsAtActionGroupResourceLevel request. The method will close the
   101  // http.Response Body if it receives an error.
   102  func (client ActionGroupsClient) CreateNotificationsAtActionGroupResourceLevelSender(req *http.Request) (future ActionGroupsCreateNotificationsAtActionGroupResourceLevelFuture, err error) {
   103  	var resp *http.Response
   104  	future.FutureAPI = &azure.Future{}
   105  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   106  	if err != nil {
   107  		return
   108  	}
   109  	var azf azure.Future
   110  	azf, err = azure.NewFutureFromResponse(resp)
   111  	future.FutureAPI = &azf
   112  	future.Result = future.result
   113  	return
   114  }
   115  
   116  // CreateNotificationsAtActionGroupResourceLevelResponder handles the response to the CreateNotificationsAtActionGroupResourceLevel request. The method always
   117  // closes the http.Response Body.
   118  func (client ActionGroupsClient) CreateNotificationsAtActionGroupResourceLevelResponder(resp *http.Response) (result TestNotificationDetailsResponse, err error) {
   119  	err = autorest.Respond(
   120  		resp,
   121  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   122  		autorest.ByUnmarshallingJSON(&result),
   123  		autorest.ByClosing())
   124  	result.Response = autorest.Response{Response: resp}
   125  	return
   126  }
   127  
   128  // CreateNotificationsAtResourceGroupLevel send test notifications to a set of provided receivers
   129  // Parameters:
   130  // resourceGroupName - the name of the resource group. The name is case insensitive.
   131  // notificationRequest - the notification request body which includes the contact details
   132  func (client ActionGroupsClient) CreateNotificationsAtResourceGroupLevel(ctx context.Context, resourceGroupName string, notificationRequest NotificationRequestBody) (result ActionGroupsCreateNotificationsAtResourceGroupLevelFuture, err error) {
   133  	if tracing.IsEnabled() {
   134  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.CreateNotificationsAtResourceGroupLevel")
   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: client.SubscriptionID,
   145  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   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  		{TargetValue: notificationRequest,
   150  			Constraints: []validation.Constraint{{Target: "notificationRequest.AlertType", Name: validation.Null, Rule: true,
   151  				Chain: []validation.Constraint{{Target: "notificationRequest.AlertType", Name: validation.MaxLength, Rule: 30, Chain: nil}}}}}}); err != nil {
   152  		return result, validation.NewError("insights.ActionGroupsClient", "CreateNotificationsAtResourceGroupLevel", err.Error())
   153  	}
   154  
   155  	req, err := client.CreateNotificationsAtResourceGroupLevelPreparer(ctx, resourceGroupName, notificationRequest)
   156  	if err != nil {
   157  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateNotificationsAtResourceGroupLevel", nil, "Failure preparing request")
   158  		return
   159  	}
   160  
   161  	result, err = client.CreateNotificationsAtResourceGroupLevelSender(req)
   162  	if err != nil {
   163  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateNotificationsAtResourceGroupLevel", result.Response(), "Failure sending request")
   164  		return
   165  	}
   166  
   167  	return
   168  }
   169  
   170  // CreateNotificationsAtResourceGroupLevelPreparer prepares the CreateNotificationsAtResourceGroupLevel request.
   171  func (client ActionGroupsClient) CreateNotificationsAtResourceGroupLevelPreparer(ctx context.Context, resourceGroupName string, notificationRequest NotificationRequestBody) (*http.Request, error) {
   172  	pathParameters := map[string]interface{}{
   173  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   174  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   175  	}
   176  
   177  	const APIVersion = "2022-06-01"
   178  	queryParameters := map[string]interface{}{
   179  		"api-version": APIVersion,
   180  	}
   181  
   182  	preparer := autorest.CreatePreparer(
   183  		autorest.AsContentType("application/json; charset=utf-8"),
   184  		autorest.AsPost(),
   185  		autorest.WithBaseURL(client.BaseURI),
   186  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications", pathParameters),
   187  		autorest.WithJSON(notificationRequest),
   188  		autorest.WithQueryParameters(queryParameters))
   189  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   190  }
   191  
   192  // CreateNotificationsAtResourceGroupLevelSender sends the CreateNotificationsAtResourceGroupLevel request. The method will close the
   193  // http.Response Body if it receives an error.
   194  func (client ActionGroupsClient) CreateNotificationsAtResourceGroupLevelSender(req *http.Request) (future ActionGroupsCreateNotificationsAtResourceGroupLevelFuture, err error) {
   195  	var resp *http.Response
   196  	future.FutureAPI = &azure.Future{}
   197  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   198  	if err != nil {
   199  		return
   200  	}
   201  	var azf azure.Future
   202  	azf, err = azure.NewFutureFromResponse(resp)
   203  	future.FutureAPI = &azf
   204  	future.Result = future.result
   205  	return
   206  }
   207  
   208  // CreateNotificationsAtResourceGroupLevelResponder handles the response to the CreateNotificationsAtResourceGroupLevel request. The method always
   209  // closes the http.Response Body.
   210  func (client ActionGroupsClient) CreateNotificationsAtResourceGroupLevelResponder(resp *http.Response) (result TestNotificationDetailsResponse, err error) {
   211  	err = autorest.Respond(
   212  		resp,
   213  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   214  		autorest.ByUnmarshallingJSON(&result),
   215  		autorest.ByClosing())
   216  	result.Response = autorest.Response{Response: resp}
   217  	return
   218  }
   219  
   220  // CreateOrUpdate create a new action group or update an existing one.
   221  // Parameters:
   222  // resourceGroupName - the name of the resource group. The name is case insensitive.
   223  // actionGroupName - the name of the action group.
   224  // actionGroup - the action group to create or use for the update.
   225  func (client ActionGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource) (result ActionGroupResource, err error) {
   226  	if tracing.IsEnabled() {
   227  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.CreateOrUpdate")
   228  		defer func() {
   229  			sc := -1
   230  			if result.Response.Response != nil {
   231  				sc = result.Response.Response.StatusCode
   232  			}
   233  			tracing.EndSpan(ctx, sc, err)
   234  		}()
   235  	}
   236  	if err := validation.Validate([]validation.Validation{
   237  		{TargetValue: resourceGroupName,
   238  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   239  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   240  		{TargetValue: actionGroup,
   241  			Constraints: []validation.Constraint{{Target: "actionGroup.ActionGroup", Name: validation.Null, Rule: false,
   242  				Chain: []validation.Constraint{{Target: "actionGroup.ActionGroup.GroupShortName", Name: validation.Null, Rule: true,
   243  					Chain: []validation.Constraint{{Target: "actionGroup.ActionGroup.GroupShortName", Name: validation.MaxLength, Rule: 12, Chain: nil}}},
   244  					{Target: "actionGroup.ActionGroup.Enabled", Name: validation.Null, Rule: true, Chain: nil},
   245  				}}}},
   246  		{TargetValue: client.SubscriptionID,
   247  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   248  		return result, validation.NewError("insights.ActionGroupsClient", "CreateOrUpdate", err.Error())
   249  	}
   250  
   251  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, actionGroupName, actionGroup)
   252  	if err != nil {
   253  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", nil, "Failure preparing request")
   254  		return
   255  	}
   256  
   257  	resp, err := client.CreateOrUpdateSender(req)
   258  	if err != nil {
   259  		result.Response = autorest.Response{Response: resp}
   260  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", resp, "Failure sending request")
   261  		return
   262  	}
   263  
   264  	result, err = client.CreateOrUpdateResponder(resp)
   265  	if err != nil {
   266  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", resp, "Failure responding to request")
   267  		return
   268  	}
   269  
   270  	return
   271  }
   272  
   273  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
   274  func (client ActionGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource) (*http.Request, error) {
   275  	pathParameters := map[string]interface{}{
   276  		"actionGroupName":   autorest.Encode("path", actionGroupName),
   277  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   278  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   279  	}
   280  
   281  	const APIVersion = "2022-06-01"
   282  	queryParameters := map[string]interface{}{
   283  		"api-version": APIVersion,
   284  	}
   285  
   286  	preparer := autorest.CreatePreparer(
   287  		autorest.AsContentType("application/json; charset=utf-8"),
   288  		autorest.AsPut(),
   289  		autorest.WithBaseURL(client.BaseURI),
   290  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", pathParameters),
   291  		autorest.WithJSON(actionGroup),
   292  		autorest.WithQueryParameters(queryParameters))
   293  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   294  }
   295  
   296  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   297  // http.Response Body if it receives an error.
   298  func (client ActionGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
   299  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   300  }
   301  
   302  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   303  // closes the http.Response Body.
   304  func (client ActionGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ActionGroupResource, err error) {
   305  	err = autorest.Respond(
   306  		resp,
   307  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   308  		autorest.ByUnmarshallingJSON(&result),
   309  		autorest.ByClosing())
   310  	result.Response = autorest.Response{Response: resp}
   311  	return
   312  }
   313  
   314  // Delete delete an action group.
   315  // Parameters:
   316  // resourceGroupName - the name of the resource group. The name is case insensitive.
   317  // actionGroupName - the name of the action group.
   318  func (client ActionGroupsClient) Delete(ctx context.Context, resourceGroupName string, actionGroupName string) (result autorest.Response, err error) {
   319  	if tracing.IsEnabled() {
   320  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Delete")
   321  		defer func() {
   322  			sc := -1
   323  			if result.Response != nil {
   324  				sc = result.Response.StatusCode
   325  			}
   326  			tracing.EndSpan(ctx, sc, err)
   327  		}()
   328  	}
   329  	if err := validation.Validate([]validation.Validation{
   330  		{TargetValue: resourceGroupName,
   331  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   332  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   333  		{TargetValue: client.SubscriptionID,
   334  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   335  		return result, validation.NewError("insights.ActionGroupsClient", "Delete", err.Error())
   336  	}
   337  
   338  	req, err := client.DeletePreparer(ctx, resourceGroupName, actionGroupName)
   339  	if err != nil {
   340  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", nil, "Failure preparing request")
   341  		return
   342  	}
   343  
   344  	resp, err := client.DeleteSender(req)
   345  	if err != nil {
   346  		result.Response = resp
   347  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", resp, "Failure sending request")
   348  		return
   349  	}
   350  
   351  	result, err = client.DeleteResponder(resp)
   352  	if err != nil {
   353  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", resp, "Failure responding to request")
   354  		return
   355  	}
   356  
   357  	return
   358  }
   359  
   360  // DeletePreparer prepares the Delete request.
   361  func (client ActionGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, actionGroupName string) (*http.Request, error) {
   362  	pathParameters := map[string]interface{}{
   363  		"actionGroupName":   autorest.Encode("path", actionGroupName),
   364  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   365  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   366  	}
   367  
   368  	const APIVersion = "2022-06-01"
   369  	queryParameters := map[string]interface{}{
   370  		"api-version": APIVersion,
   371  	}
   372  
   373  	preparer := autorest.CreatePreparer(
   374  		autorest.AsDelete(),
   375  		autorest.WithBaseURL(client.BaseURI),
   376  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", pathParameters),
   377  		autorest.WithQueryParameters(queryParameters))
   378  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   379  }
   380  
   381  // DeleteSender sends the Delete request. The method will close the
   382  // http.Response Body if it receives an error.
   383  func (client ActionGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) {
   384  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   385  }
   386  
   387  // DeleteResponder handles the response to the Delete request. The method always
   388  // closes the http.Response Body.
   389  func (client ActionGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   390  	err = autorest.Respond(
   391  		resp,
   392  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
   393  		autorest.ByClosing())
   394  	result.Response = resp
   395  	return
   396  }
   397  
   398  // EnableReceiver enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled.
   399  // This operation is only supported for Email or SMS receivers.
   400  // Parameters:
   401  // resourceGroupName - the name of the resource group. The name is case insensitive.
   402  // actionGroupName - the name of the action group.
   403  // enableRequest - the receiver to re-enable.
   404  func (client ActionGroupsClient) EnableReceiver(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest) (result autorest.Response, err error) {
   405  	if tracing.IsEnabled() {
   406  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.EnableReceiver")
   407  		defer func() {
   408  			sc := -1
   409  			if result.Response != nil {
   410  				sc = result.Response.StatusCode
   411  			}
   412  			tracing.EndSpan(ctx, sc, err)
   413  		}()
   414  	}
   415  	if err := validation.Validate([]validation.Validation{
   416  		{TargetValue: resourceGroupName,
   417  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   418  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   419  		{TargetValue: enableRequest,
   420  			Constraints: []validation.Constraint{{Target: "enableRequest.ReceiverName", Name: validation.Null, Rule: true, Chain: nil}}},
   421  		{TargetValue: client.SubscriptionID,
   422  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   423  		return result, validation.NewError("insights.ActionGroupsClient", "EnableReceiver", err.Error())
   424  	}
   425  
   426  	req, err := client.EnableReceiverPreparer(ctx, resourceGroupName, actionGroupName, enableRequest)
   427  	if err != nil {
   428  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", nil, "Failure preparing request")
   429  		return
   430  	}
   431  
   432  	resp, err := client.EnableReceiverSender(req)
   433  	if err != nil {
   434  		result.Response = resp
   435  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", resp, "Failure sending request")
   436  		return
   437  	}
   438  
   439  	result, err = client.EnableReceiverResponder(resp)
   440  	if err != nil {
   441  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", resp, "Failure responding to request")
   442  		return
   443  	}
   444  
   445  	return
   446  }
   447  
   448  // EnableReceiverPreparer prepares the EnableReceiver request.
   449  func (client ActionGroupsClient) EnableReceiverPreparer(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest) (*http.Request, error) {
   450  	pathParameters := map[string]interface{}{
   451  		"actionGroupName":   autorest.Encode("path", actionGroupName),
   452  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   453  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   454  	}
   455  
   456  	const APIVersion = "2022-06-01"
   457  	queryParameters := map[string]interface{}{
   458  		"api-version": APIVersion,
   459  	}
   460  
   461  	preparer := autorest.CreatePreparer(
   462  		autorest.AsContentType("application/json; charset=utf-8"),
   463  		autorest.AsPost(),
   464  		autorest.WithBaseURL(client.BaseURI),
   465  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe", pathParameters),
   466  		autorest.WithJSON(enableRequest),
   467  		autorest.WithQueryParameters(queryParameters))
   468  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   469  }
   470  
   471  // EnableReceiverSender sends the EnableReceiver request. The method will close the
   472  // http.Response Body if it receives an error.
   473  func (client ActionGroupsClient) EnableReceiverSender(req *http.Request) (*http.Response, error) {
   474  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   475  }
   476  
   477  // EnableReceiverResponder handles the response to the EnableReceiver request. The method always
   478  // closes the http.Response Body.
   479  func (client ActionGroupsClient) EnableReceiverResponder(resp *http.Response) (result autorest.Response, err error) {
   480  	err = autorest.Respond(
   481  		resp,
   482  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   483  		autorest.ByClosing())
   484  	result.Response = resp
   485  	return
   486  }
   487  
   488  // Get get an action group.
   489  // Parameters:
   490  // resourceGroupName - the name of the resource group. The name is case insensitive.
   491  // actionGroupName - the name of the action group.
   492  func (client ActionGroupsClient) Get(ctx context.Context, resourceGroupName string, actionGroupName string) (result ActionGroupResource, err error) {
   493  	if tracing.IsEnabled() {
   494  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Get")
   495  		defer func() {
   496  			sc := -1
   497  			if result.Response.Response != nil {
   498  				sc = result.Response.Response.StatusCode
   499  			}
   500  			tracing.EndSpan(ctx, sc, err)
   501  		}()
   502  	}
   503  	if err := validation.Validate([]validation.Validation{
   504  		{TargetValue: resourceGroupName,
   505  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   506  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   507  		{TargetValue: client.SubscriptionID,
   508  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   509  		return result, validation.NewError("insights.ActionGroupsClient", "Get", err.Error())
   510  	}
   511  
   512  	req, err := client.GetPreparer(ctx, resourceGroupName, actionGroupName)
   513  	if err != nil {
   514  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", nil, "Failure preparing request")
   515  		return
   516  	}
   517  
   518  	resp, err := client.GetSender(req)
   519  	if err != nil {
   520  		result.Response = autorest.Response{Response: resp}
   521  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", resp, "Failure sending request")
   522  		return
   523  	}
   524  
   525  	result, err = client.GetResponder(resp)
   526  	if err != nil {
   527  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", resp, "Failure responding to request")
   528  		return
   529  	}
   530  
   531  	return
   532  }
   533  
   534  // GetPreparer prepares the Get request.
   535  func (client ActionGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, actionGroupName string) (*http.Request, error) {
   536  	pathParameters := map[string]interface{}{
   537  		"actionGroupName":   autorest.Encode("path", actionGroupName),
   538  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   539  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   540  	}
   541  
   542  	const APIVersion = "2022-06-01"
   543  	queryParameters := map[string]interface{}{
   544  		"api-version": APIVersion,
   545  	}
   546  
   547  	preparer := autorest.CreatePreparer(
   548  		autorest.AsGet(),
   549  		autorest.WithBaseURL(client.BaseURI),
   550  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", pathParameters),
   551  		autorest.WithQueryParameters(queryParameters))
   552  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   553  }
   554  
   555  // GetSender sends the Get request. The method will close the
   556  // http.Response Body if it receives an error.
   557  func (client ActionGroupsClient) GetSender(req *http.Request) (*http.Response, error) {
   558  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   559  }
   560  
   561  // GetResponder handles the response to the Get request. The method always
   562  // closes the http.Response Body.
   563  func (client ActionGroupsClient) GetResponder(resp *http.Response) (result ActionGroupResource, err error) {
   564  	err = autorest.Respond(
   565  		resp,
   566  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   567  		autorest.ByUnmarshallingJSON(&result),
   568  		autorest.ByClosing())
   569  	result.Response = autorest.Response{Response: resp}
   570  	return
   571  }
   572  
   573  // GetTestNotifications get the test notifications by the notification id
   574  // Parameters:
   575  // notificationID - the notification id
   576  func (client ActionGroupsClient) GetTestNotifications(ctx context.Context, notificationID string) (result TestNotificationDetailsResponse, err error) {
   577  	if tracing.IsEnabled() {
   578  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.GetTestNotifications")
   579  		defer func() {
   580  			sc := -1
   581  			if result.Response.Response != nil {
   582  				sc = result.Response.Response.StatusCode
   583  			}
   584  			tracing.EndSpan(ctx, sc, err)
   585  		}()
   586  	}
   587  	if err := validation.Validate([]validation.Validation{
   588  		{TargetValue: client.SubscriptionID,
   589  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   590  		return result, validation.NewError("insights.ActionGroupsClient", "GetTestNotifications", err.Error())
   591  	}
   592  
   593  	req, err := client.GetTestNotificationsPreparer(ctx, notificationID)
   594  	if err != nil {
   595  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotifications", nil, "Failure preparing request")
   596  		return
   597  	}
   598  
   599  	resp, err := client.GetTestNotificationsSender(req)
   600  	if err != nil {
   601  		result.Response = autorest.Response{Response: resp}
   602  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotifications", resp, "Failure sending request")
   603  		return
   604  	}
   605  
   606  	result, err = client.GetTestNotificationsResponder(resp)
   607  	if err != nil {
   608  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotifications", resp, "Failure responding to request")
   609  		return
   610  	}
   611  
   612  	return
   613  }
   614  
   615  // GetTestNotificationsPreparer prepares the GetTestNotifications request.
   616  func (client ActionGroupsClient) GetTestNotificationsPreparer(ctx context.Context, notificationID string) (*http.Request, error) {
   617  	pathParameters := map[string]interface{}{
   618  		"notificationId": autorest.Encode("path", notificationID),
   619  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   620  	}
   621  
   622  	const APIVersion = "2022-06-01"
   623  	queryParameters := map[string]interface{}{
   624  		"api-version": APIVersion,
   625  	}
   626  
   627  	preparer := autorest.CreatePreparer(
   628  		autorest.AsGet(),
   629  		autorest.WithBaseURL(client.BaseURI),
   630  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}", pathParameters),
   631  		autorest.WithQueryParameters(queryParameters))
   632  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   633  }
   634  
   635  // GetTestNotificationsSender sends the GetTestNotifications request. The method will close the
   636  // http.Response Body if it receives an error.
   637  func (client ActionGroupsClient) GetTestNotificationsSender(req *http.Request) (*http.Response, error) {
   638  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   639  }
   640  
   641  // GetTestNotificationsResponder handles the response to the GetTestNotifications request. The method always
   642  // closes the http.Response Body.
   643  func (client ActionGroupsClient) GetTestNotificationsResponder(resp *http.Response) (result TestNotificationDetailsResponse, err error) {
   644  	err = autorest.Respond(
   645  		resp,
   646  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   647  		autorest.ByUnmarshallingJSON(&result),
   648  		autorest.ByClosing())
   649  	result.Response = autorest.Response{Response: resp}
   650  	return
   651  }
   652  
   653  // GetTestNotificationsAtActionGroupResourceLevel get the test notifications by the notification id
   654  // Parameters:
   655  // resourceGroupName - the name of the resource group. The name is case insensitive.
   656  // actionGroupName - the name of the action group.
   657  // notificationID - the notification id
   658  func (client ActionGroupsClient) GetTestNotificationsAtActionGroupResourceLevel(ctx context.Context, resourceGroupName string, actionGroupName string, notificationID string) (result TestNotificationDetailsResponse, err error) {
   659  	if tracing.IsEnabled() {
   660  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.GetTestNotificationsAtActionGroupResourceLevel")
   661  		defer func() {
   662  			sc := -1
   663  			if result.Response.Response != nil {
   664  				sc = result.Response.Response.StatusCode
   665  			}
   666  			tracing.EndSpan(ctx, sc, err)
   667  		}()
   668  	}
   669  	if err := validation.Validate([]validation.Validation{
   670  		{TargetValue: client.SubscriptionID,
   671  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   672  		{TargetValue: resourceGroupName,
   673  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   674  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   675  		return result, validation.NewError("insights.ActionGroupsClient", "GetTestNotificationsAtActionGroupResourceLevel", err.Error())
   676  	}
   677  
   678  	req, err := client.GetTestNotificationsAtActionGroupResourceLevelPreparer(ctx, resourceGroupName, actionGroupName, notificationID)
   679  	if err != nil {
   680  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotificationsAtActionGroupResourceLevel", nil, "Failure preparing request")
   681  		return
   682  	}
   683  
   684  	resp, err := client.GetTestNotificationsAtActionGroupResourceLevelSender(req)
   685  	if err != nil {
   686  		result.Response = autorest.Response{Response: resp}
   687  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotificationsAtActionGroupResourceLevel", resp, "Failure sending request")
   688  		return
   689  	}
   690  
   691  	result, err = client.GetTestNotificationsAtActionGroupResourceLevelResponder(resp)
   692  	if err != nil {
   693  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotificationsAtActionGroupResourceLevel", resp, "Failure responding to request")
   694  		return
   695  	}
   696  
   697  	return
   698  }
   699  
   700  // GetTestNotificationsAtActionGroupResourceLevelPreparer prepares the GetTestNotificationsAtActionGroupResourceLevel request.
   701  func (client ActionGroupsClient) GetTestNotificationsAtActionGroupResourceLevelPreparer(ctx context.Context, resourceGroupName string, actionGroupName string, notificationID string) (*http.Request, error) {
   702  	pathParameters := map[string]interface{}{
   703  		"actionGroupName":   autorest.Encode("path", actionGroupName),
   704  		"notificationId":    autorest.Encode("path", notificationID),
   705  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   706  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   707  	}
   708  
   709  	const APIVersion = "2022-06-01"
   710  	queryParameters := map[string]interface{}{
   711  		"api-version": APIVersion,
   712  	}
   713  
   714  	preparer := autorest.CreatePreparer(
   715  		autorest.AsGet(),
   716  		autorest.WithBaseURL(client.BaseURI),
   717  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}", pathParameters),
   718  		autorest.WithQueryParameters(queryParameters))
   719  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   720  }
   721  
   722  // GetTestNotificationsAtActionGroupResourceLevelSender sends the GetTestNotificationsAtActionGroupResourceLevel request. The method will close the
   723  // http.Response Body if it receives an error.
   724  func (client ActionGroupsClient) GetTestNotificationsAtActionGroupResourceLevelSender(req *http.Request) (*http.Response, error) {
   725  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   726  }
   727  
   728  // GetTestNotificationsAtActionGroupResourceLevelResponder handles the response to the GetTestNotificationsAtActionGroupResourceLevel request. The method always
   729  // closes the http.Response Body.
   730  func (client ActionGroupsClient) GetTestNotificationsAtActionGroupResourceLevelResponder(resp *http.Response) (result TestNotificationDetailsResponse, err error) {
   731  	err = autorest.Respond(
   732  		resp,
   733  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   734  		autorest.ByUnmarshallingJSON(&result),
   735  		autorest.ByClosing())
   736  	result.Response = autorest.Response{Response: resp}
   737  	return
   738  }
   739  
   740  // GetTestNotificationsAtResourceGroupLevel get the test notifications by the notification id
   741  // Parameters:
   742  // resourceGroupName - the name of the resource group. The name is case insensitive.
   743  // notificationID - the notification id
   744  func (client ActionGroupsClient) GetTestNotificationsAtResourceGroupLevel(ctx context.Context, resourceGroupName string, notificationID string) (result TestNotificationDetailsResponse, err error) {
   745  	if tracing.IsEnabled() {
   746  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.GetTestNotificationsAtResourceGroupLevel")
   747  		defer func() {
   748  			sc := -1
   749  			if result.Response.Response != nil {
   750  				sc = result.Response.Response.StatusCode
   751  			}
   752  			tracing.EndSpan(ctx, sc, err)
   753  		}()
   754  	}
   755  	if err := validation.Validate([]validation.Validation{
   756  		{TargetValue: client.SubscriptionID,
   757  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   758  		{TargetValue: resourceGroupName,
   759  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   760  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   761  		return result, validation.NewError("insights.ActionGroupsClient", "GetTestNotificationsAtResourceGroupLevel", err.Error())
   762  	}
   763  
   764  	req, err := client.GetTestNotificationsAtResourceGroupLevelPreparer(ctx, resourceGroupName, notificationID)
   765  	if err != nil {
   766  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotificationsAtResourceGroupLevel", nil, "Failure preparing request")
   767  		return
   768  	}
   769  
   770  	resp, err := client.GetTestNotificationsAtResourceGroupLevelSender(req)
   771  	if err != nil {
   772  		result.Response = autorest.Response{Response: resp}
   773  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotificationsAtResourceGroupLevel", resp, "Failure sending request")
   774  		return
   775  	}
   776  
   777  	result, err = client.GetTestNotificationsAtResourceGroupLevelResponder(resp)
   778  	if err != nil {
   779  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "GetTestNotificationsAtResourceGroupLevel", resp, "Failure responding to request")
   780  		return
   781  	}
   782  
   783  	return
   784  }
   785  
   786  // GetTestNotificationsAtResourceGroupLevelPreparer prepares the GetTestNotificationsAtResourceGroupLevel request.
   787  func (client ActionGroupsClient) GetTestNotificationsAtResourceGroupLevelPreparer(ctx context.Context, resourceGroupName string, notificationID string) (*http.Request, error) {
   788  	pathParameters := map[string]interface{}{
   789  		"notificationId":    autorest.Encode("path", notificationID),
   790  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   791  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   792  	}
   793  
   794  	const APIVersion = "2022-06-01"
   795  	queryParameters := map[string]interface{}{
   796  		"api-version": APIVersion,
   797  	}
   798  
   799  	preparer := autorest.CreatePreparer(
   800  		autorest.AsGet(),
   801  		autorest.WithBaseURL(client.BaseURI),
   802  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}", pathParameters),
   803  		autorest.WithQueryParameters(queryParameters))
   804  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   805  }
   806  
   807  // GetTestNotificationsAtResourceGroupLevelSender sends the GetTestNotificationsAtResourceGroupLevel request. The method will close the
   808  // http.Response Body if it receives an error.
   809  func (client ActionGroupsClient) GetTestNotificationsAtResourceGroupLevelSender(req *http.Request) (*http.Response, error) {
   810  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   811  }
   812  
   813  // GetTestNotificationsAtResourceGroupLevelResponder handles the response to the GetTestNotificationsAtResourceGroupLevel request. The method always
   814  // closes the http.Response Body.
   815  func (client ActionGroupsClient) GetTestNotificationsAtResourceGroupLevelResponder(resp *http.Response) (result TestNotificationDetailsResponse, err error) {
   816  	err = autorest.Respond(
   817  		resp,
   818  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   819  		autorest.ByUnmarshallingJSON(&result),
   820  		autorest.ByClosing())
   821  	result.Response = autorest.Response{Response: resp}
   822  	return
   823  }
   824  
   825  // ListByResourceGroup get a list of all action groups in a resource group.
   826  // Parameters:
   827  // resourceGroupName - the name of the resource group. The name is case insensitive.
   828  func (client ActionGroupsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ActionGroupList, err error) {
   829  	if tracing.IsEnabled() {
   830  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.ListByResourceGroup")
   831  		defer func() {
   832  			sc := -1
   833  			if result.Response.Response != nil {
   834  				sc = result.Response.Response.StatusCode
   835  			}
   836  			tracing.EndSpan(ctx, sc, err)
   837  		}()
   838  	}
   839  	if err := validation.Validate([]validation.Validation{
   840  		{TargetValue: resourceGroupName,
   841  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
   842  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
   843  		{TargetValue: client.SubscriptionID,
   844  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   845  		return result, validation.NewError("insights.ActionGroupsClient", "ListByResourceGroup", err.Error())
   846  	}
   847  
   848  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
   849  	if err != nil {
   850  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", nil, "Failure preparing request")
   851  		return
   852  	}
   853  
   854  	resp, err := client.ListByResourceGroupSender(req)
   855  	if err != nil {
   856  		result.Response = autorest.Response{Response: resp}
   857  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", resp, "Failure sending request")
   858  		return
   859  	}
   860  
   861  	result, err = client.ListByResourceGroupResponder(resp)
   862  	if err != nil {
   863  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", resp, "Failure responding to request")
   864  		return
   865  	}
   866  
   867  	return
   868  }
   869  
   870  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   871  func (client ActionGroupsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   872  	pathParameters := map[string]interface{}{
   873  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   874  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   875  	}
   876  
   877  	const APIVersion = "2022-06-01"
   878  	queryParameters := map[string]interface{}{
   879  		"api-version": APIVersion,
   880  	}
   881  
   882  	preparer := autorest.CreatePreparer(
   883  		autorest.AsGet(),
   884  		autorest.WithBaseURL(client.BaseURI),
   885  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups", pathParameters),
   886  		autorest.WithQueryParameters(queryParameters))
   887  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   888  }
   889  
   890  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   891  // http.Response Body if it receives an error.
   892  func (client ActionGroupsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   893  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   894  }
   895  
   896  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   897  // closes the http.Response Body.
   898  func (client ActionGroupsClient) ListByResourceGroupResponder(resp *http.Response) (result ActionGroupList, err error) {
   899  	err = autorest.Respond(
   900  		resp,
   901  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   902  		autorest.ByUnmarshallingJSON(&result),
   903  		autorest.ByClosing())
   904  	result.Response = autorest.Response{Response: resp}
   905  	return
   906  }
   907  
   908  // ListBySubscriptionID get a list of all action groups in a subscription.
   909  func (client ActionGroupsClient) ListBySubscriptionID(ctx context.Context) (result ActionGroupList, err error) {
   910  	if tracing.IsEnabled() {
   911  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.ListBySubscriptionID")
   912  		defer func() {
   913  			sc := -1
   914  			if result.Response.Response != nil {
   915  				sc = result.Response.Response.StatusCode
   916  			}
   917  			tracing.EndSpan(ctx, sc, err)
   918  		}()
   919  	}
   920  	if err := validation.Validate([]validation.Validation{
   921  		{TargetValue: client.SubscriptionID,
   922  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
   923  		return result, validation.NewError("insights.ActionGroupsClient", "ListBySubscriptionID", err.Error())
   924  	}
   925  
   926  	req, err := client.ListBySubscriptionIDPreparer(ctx)
   927  	if err != nil {
   928  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", nil, "Failure preparing request")
   929  		return
   930  	}
   931  
   932  	resp, err := client.ListBySubscriptionIDSender(req)
   933  	if err != nil {
   934  		result.Response = autorest.Response{Response: resp}
   935  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", resp, "Failure sending request")
   936  		return
   937  	}
   938  
   939  	result, err = client.ListBySubscriptionIDResponder(resp)
   940  	if err != nil {
   941  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", resp, "Failure responding to request")
   942  		return
   943  	}
   944  
   945  	return
   946  }
   947  
   948  // ListBySubscriptionIDPreparer prepares the ListBySubscriptionID request.
   949  func (client ActionGroupsClient) ListBySubscriptionIDPreparer(ctx context.Context) (*http.Request, error) {
   950  	pathParameters := map[string]interface{}{
   951  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   952  	}
   953  
   954  	const APIVersion = "2022-06-01"
   955  	queryParameters := map[string]interface{}{
   956  		"api-version": APIVersion,
   957  	}
   958  
   959  	preparer := autorest.CreatePreparer(
   960  		autorest.AsGet(),
   961  		autorest.WithBaseURL(client.BaseURI),
   962  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups", pathParameters),
   963  		autorest.WithQueryParameters(queryParameters))
   964  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   965  }
   966  
   967  // ListBySubscriptionIDSender sends the ListBySubscriptionID request. The method will close the
   968  // http.Response Body if it receives an error.
   969  func (client ActionGroupsClient) ListBySubscriptionIDSender(req *http.Request) (*http.Response, error) {
   970  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   971  }
   972  
   973  // ListBySubscriptionIDResponder handles the response to the ListBySubscriptionID request. The method always
   974  // closes the http.Response Body.
   975  func (client ActionGroupsClient) ListBySubscriptionIDResponder(resp *http.Response) (result ActionGroupList, err error) {
   976  	err = autorest.Respond(
   977  		resp,
   978  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   979  		autorest.ByUnmarshallingJSON(&result),
   980  		autorest.ByClosing())
   981  	result.Response = autorest.Response{Response: resp}
   982  	return
   983  }
   984  
   985  // PostTestNotifications send test notifications to a set of provided receivers
   986  // Parameters:
   987  // notificationRequest - the notification request body which includes the contact details
   988  func (client ActionGroupsClient) PostTestNotifications(ctx context.Context, notificationRequest NotificationRequestBody) (result ActionGroupsPostTestNotificationsFuture, err error) {
   989  	if tracing.IsEnabled() {
   990  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.PostTestNotifications")
   991  		defer func() {
   992  			sc := -1
   993  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   994  				sc = result.FutureAPI.Response().StatusCode
   995  			}
   996  			tracing.EndSpan(ctx, sc, err)
   997  		}()
   998  	}
   999  	if err := validation.Validate([]validation.Validation{
  1000  		{TargetValue: client.SubscriptionID,
  1001  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
  1002  		{TargetValue: notificationRequest,
  1003  			Constraints: []validation.Constraint{{Target: "notificationRequest.AlertType", Name: validation.Null, Rule: true,
  1004  				Chain: []validation.Constraint{{Target: "notificationRequest.AlertType", Name: validation.MaxLength, Rule: 30, Chain: nil}}}}}}); err != nil {
  1005  		return result, validation.NewError("insights.ActionGroupsClient", "PostTestNotifications", err.Error())
  1006  	}
  1007  
  1008  	req, err := client.PostTestNotificationsPreparer(ctx, notificationRequest)
  1009  	if err != nil {
  1010  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "PostTestNotifications", nil, "Failure preparing request")
  1011  		return
  1012  	}
  1013  
  1014  	result, err = client.PostTestNotificationsSender(req)
  1015  	if err != nil {
  1016  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "PostTestNotifications", result.Response(), "Failure sending request")
  1017  		return
  1018  	}
  1019  
  1020  	return
  1021  }
  1022  
  1023  // PostTestNotificationsPreparer prepares the PostTestNotifications request.
  1024  func (client ActionGroupsClient) PostTestNotificationsPreparer(ctx context.Context, notificationRequest NotificationRequestBody) (*http.Request, error) {
  1025  	pathParameters := map[string]interface{}{
  1026  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
  1027  	}
  1028  
  1029  	const APIVersion = "2022-06-01"
  1030  	queryParameters := map[string]interface{}{
  1031  		"api-version": APIVersion,
  1032  	}
  1033  
  1034  	preparer := autorest.CreatePreparer(
  1035  		autorest.AsContentType("application/json; charset=utf-8"),
  1036  		autorest.AsPost(),
  1037  		autorest.WithBaseURL(client.BaseURI),
  1038  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications", pathParameters),
  1039  		autorest.WithJSON(notificationRequest),
  1040  		autorest.WithQueryParameters(queryParameters))
  1041  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1042  }
  1043  
  1044  // PostTestNotificationsSender sends the PostTestNotifications request. The method will close the
  1045  // http.Response Body if it receives an error.
  1046  func (client ActionGroupsClient) PostTestNotificationsSender(req *http.Request) (future ActionGroupsPostTestNotificationsFuture, err error) {
  1047  	var resp *http.Response
  1048  	future.FutureAPI = &azure.Future{}
  1049  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1050  	if err != nil {
  1051  		return
  1052  	}
  1053  	var azf azure.Future
  1054  	azf, err = azure.NewFutureFromResponse(resp)
  1055  	future.FutureAPI = &azf
  1056  	future.Result = future.result
  1057  	return
  1058  }
  1059  
  1060  // PostTestNotificationsResponder handles the response to the PostTestNotifications request. The method always
  1061  // closes the http.Response Body.
  1062  func (client ActionGroupsClient) PostTestNotificationsResponder(resp *http.Response) (result TestNotificationDetailsResponse, err error) {
  1063  	err = autorest.Respond(
  1064  		resp,
  1065  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
  1066  		autorest.ByUnmarshallingJSON(&result),
  1067  		autorest.ByClosing())
  1068  	result.Response = autorest.Response{Response: resp}
  1069  	return
  1070  }
  1071  
  1072  // Update updates an existing action group's tags. To update other fields use the CreateOrUpdate method.
  1073  // Parameters:
  1074  // resourceGroupName - the name of the resource group. The name is case insensitive.
  1075  // actionGroupName - the name of the action group.
  1076  // actionGroupPatch - parameters supplied to the operation.
  1077  func (client ActionGroupsClient) Update(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch ActionGroupPatchBody) (result ActionGroupResource, err error) {
  1078  	if tracing.IsEnabled() {
  1079  		ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Update")
  1080  		defer func() {
  1081  			sc := -1
  1082  			if result.Response.Response != nil {
  1083  				sc = result.Response.Response.StatusCode
  1084  			}
  1085  			tracing.EndSpan(ctx, sc, err)
  1086  		}()
  1087  	}
  1088  	if err := validation.Validate([]validation.Validation{
  1089  		{TargetValue: client.SubscriptionID,
  1090  			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}},
  1091  		{TargetValue: resourceGroupName,
  1092  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
  1093  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
  1094  		return result, validation.NewError("insights.ActionGroupsClient", "Update", err.Error())
  1095  	}
  1096  
  1097  	req, err := client.UpdatePreparer(ctx, resourceGroupName, actionGroupName, actionGroupPatch)
  1098  	if err != nil {
  1099  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", nil, "Failure preparing request")
  1100  		return
  1101  	}
  1102  
  1103  	resp, err := client.UpdateSender(req)
  1104  	if err != nil {
  1105  		result.Response = autorest.Response{Response: resp}
  1106  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", resp, "Failure sending request")
  1107  		return
  1108  	}
  1109  
  1110  	result, err = client.UpdateResponder(resp)
  1111  	if err != nil {
  1112  		err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", resp, "Failure responding to request")
  1113  		return
  1114  	}
  1115  
  1116  	return
  1117  }
  1118  
  1119  // UpdatePreparer prepares the Update request.
  1120  func (client ActionGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch ActionGroupPatchBody) (*http.Request, error) {
  1121  	pathParameters := map[string]interface{}{
  1122  		"actionGroupName":   autorest.Encode("path", actionGroupName),
  1123  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
  1124  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
  1125  	}
  1126  
  1127  	const APIVersion = "2022-06-01"
  1128  	queryParameters := map[string]interface{}{
  1129  		"api-version": APIVersion,
  1130  	}
  1131  
  1132  	preparer := autorest.CreatePreparer(
  1133  		autorest.AsContentType("application/json; charset=utf-8"),
  1134  		autorest.AsPatch(),
  1135  		autorest.WithBaseURL(client.BaseURI),
  1136  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", pathParameters),
  1137  		autorest.WithJSON(actionGroupPatch),
  1138  		autorest.WithQueryParameters(queryParameters))
  1139  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1140  }
  1141  
  1142  // UpdateSender sends the Update request. The method will close the
  1143  // http.Response Body if it receives an error.
  1144  func (client ActionGroupsClient) UpdateSender(req *http.Request) (*http.Response, error) {
  1145  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
  1146  }
  1147  
  1148  // UpdateResponder handles the response to the Update request. The method always
  1149  // closes the http.Response Body.
  1150  func (client ActionGroupsClient) UpdateResponder(resp *http.Response) (result ActionGroupResource, err error) {
  1151  	err = autorest.Respond(
  1152  		resp,
  1153  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1154  		autorest.ByUnmarshallingJSON(&result),
  1155  		autorest.ByClosing())
  1156  	result.Response = autorest.Response{Response: resp}
  1157  	return
  1158  }
  1159  

View as plain text