From 48d131d75b0da763ef3ca5ffb058ab915b5d8b13 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 17 Jun 2021 05:33:27 +0000 Subject: [PATCH] CodeGen from PR 14542 in Azure/azure-rest-api-specs Update Azure Monitor readme.{go/python}.md with the latest specs (#14542) * Update readme.{go/python}.md with the latest specs * add new tag: package-2021-04 * Update list for package-2021-04 * Fix CSharpGen adding directive and fix refs in DCR * Moving directive for all SDKs * prettier changes * directive only for go & .net * fixing go output-folder * directive, remove azure-validator, add typescript * fixing PR's LintDiff findings * fixing breaking changes * fixing go/python directives * fix go build * directive go && package-2021-04 * fix go build prev package-2021-04 * fix java build --- .../2021-04-01-preview/insights/CHANGELOG.md | 2 + .../2021-04-01-preview/insights/_meta.json | 11 + .../insights/actiongroups.go | 633 ++ .../insights/activitylogalerts.go | 545 + .../insights/activitylogs.go | 173 + .../insights/alertruleincidents.go | 205 + .../2021-04-01-preview/insights/alertrules.go | 542 + .../insights/autoscalesettings.go | 627 ++ .../2021-04-01-preview/insights/baselines.go | 154 + .../2021-04-01-preview/insights/client.go | 41 + .../insights/datacollectionendpoints.go | 636 ++ .../datacollectionruleassociations.go | 534 + .../insights/datacollectionrules.go | 636 ++ .../insights/diagnosticsettings.go | 357 + .../insights/diagnosticsettingscategory.go | 193 + .../mgmt/2021-04-01-preview/insights/enums.go | 968 ++ .../insights/eventcategories.go | 99 + .../insights/insightsapi/interfaces.go | 291 + .../insights/logprofiles.go | 444 + .../insights/metricalerts.go | 545 + .../insights/metricalertsstatus.go | 205 + .../insights/metricdefinitions.go | 116 + .../insights/metricnamespaces.go | 116 + .../2021-04-01-preview/insights/metrics.go | 163 + .../2021-04-01-preview/insights/models.go | 8740 +++++++++++++++++ .../2021-04-01-preview/insights/operations.go | 98 + .../insights/privateendpointconnections.go | 433 + .../insights/privatelinkresources.go | 247 + .../insights/privatelinkscopedresources.go | 426 + .../privatelinkscopeoperationstatus.go | 118 + .../insights/privatelinkscopes.go | 628 ++ .../insights/scheduledqueryrules.go | 558 ++ .../insights/tenantactivitylogs.go | 168 + .../2021-04-01-preview/insights/version.go | 19 + .../2021-04-01-preview/insights/vminsights.go | 105 + 35 files changed, 19776 insertions(+) create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/CHANGELOG.md create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/_meta.json create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/actiongroups.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogalerts.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogs.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/alertruleincidents.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/alertrules.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/autoscalesettings.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/baselines.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/client.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionendpoints.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionruleassociations.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionrules.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettings.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettingscategory.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/enums.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/eventcategories.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/insightsapi/interfaces.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/logprofiles.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalerts.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalertsstatus.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/metricdefinitions.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/metricnamespaces.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/metrics.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/models.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/operations.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/privateendpointconnections.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkresources.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopedresources.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopeoperationstatus.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopes.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/scheduledqueryrules.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/tenantactivitylogs.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/version.go create mode 100644 services/preview/monitor/mgmt/2021-04-01-preview/insights/vminsights.go diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/CHANGELOG.md b/services/preview/monitor/mgmt/2021-04-01-preview/insights/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/_meta.json b/services/preview/monitor/mgmt/2021-04-01-preview/insights/_meta.json new file mode 100644 index 000000000000..ec2b0144072e --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "5ffa6f90f1916423bd09855f1bfe32d2bd78ecab", + "readme": "/_/azure-rest-api-specs/specification/monitor/resource-manager/readme.md", + "tag": "package-2021-04", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2021-04 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/monitor/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/actiongroups.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/actiongroups.go new file mode 100644 index 000000000000..ce2e6509e2da --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/actiongroups.go @@ -0,0 +1,633 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ActionGroupsClient is the monitor Management Client +type ActionGroupsClient struct { + BaseClient +} + +// NewActionGroupsClient creates an instance of the ActionGroupsClient client. +func NewActionGroupsClient(subscriptionID string) ActionGroupsClient { + return NewActionGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewActionGroupsClientWithBaseURI creates an instance of the ActionGroupsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewActionGroupsClientWithBaseURI(baseURI string, subscriptionID string) ActionGroupsClient { + return ActionGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a new action group or update an existing one. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// actionGroupName - the name of the action group. +// actionGroup - the action group to create or use for the update. +func (client ActionGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource) (result ActionGroupResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: actionGroup, + Constraints: []validation.Constraint{{Target: "actionGroup.ActionGroup", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "actionGroup.ActionGroup.GroupShortName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "actionGroup.ActionGroup.GroupShortName", Name: validation.MaxLength, Rule: 12, Chain: nil}}}, + {Target: "actionGroup.ActionGroup.Enabled", Name: validation.Null, Rule: true, Chain: nil}, + }}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, actionGroupName, actionGroup) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ActionGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", pathParameters), + autorest.WithJSON(actionGroup), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ActionGroupResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an action group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// actionGroupName - the name of the action group. +func (client ActionGroupsClient) Delete(ctx context.Context, resourceGroupName string, actionGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, actionGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ActionGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, actionGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// EnableReceiver enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. +// This operation is only supported for Email or SMS receivers. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// actionGroupName - the name of the action group. +// enableRequest - the receiver to re-enable. +func (client ActionGroupsClient) EnableReceiver(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.EnableReceiver") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: enableRequest, + Constraints: []validation.Constraint{{Target: "enableRequest.ReceiverName", Name: validation.Null, Rule: true, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "EnableReceiver", err.Error()) + } + + req, err := client.EnableReceiverPreparer(ctx, resourceGroupName, actionGroupName, enableRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", nil, "Failure preparing request") + return + } + + resp, err := client.EnableReceiverSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", resp, "Failure sending request") + return + } + + result, err = client.EnableReceiverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", resp, "Failure responding to request") + return + } + + return +} + +// EnableReceiverPreparer prepares the EnableReceiver request. +func (client ActionGroupsClient) EnableReceiverPreparer(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", pathParameters), + autorest.WithJSON(enableRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// EnableReceiverSender sends the EnableReceiver request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) EnableReceiverSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// EnableReceiverResponder handles the response to the EnableReceiver request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) EnableReceiverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusConflict), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get an action group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// actionGroupName - the name of the action group. +func (client ActionGroupsClient) Get(ctx context.Context, resourceGroupName string, actionGroupName string) (result ActionGroupResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, actionGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ActionGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, actionGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) GetResponder(resp *http.Response) (result ActionGroupResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get a list of all action groups in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ActionGroupsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ActionGroupList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ActionGroupsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) ListByResourceGroupResponder(resp *http.Response) (result ActionGroupList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscriptionID get a list of all action groups in a subscription. +func (client ActionGroupsClient) ListBySubscriptionID(ctx context.Context) (result ActionGroupList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.ListBySubscriptionID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "ListBySubscriptionID", err.Error()) + } + + req, err := client.ListBySubscriptionIDPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionIDPreparer prepares the ListBySubscriptionID request. +func (client ActionGroupsClient) ListBySubscriptionIDPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionIDSender sends the ListBySubscriptionID request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) ListBySubscriptionIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionIDResponder handles the response to the ListBySubscriptionID request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) ListBySubscriptionIDResponder(resp *http.Response) (result ActionGroupList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing action group's tags. To update other fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// actionGroupName - the name of the action group. +// actionGroupPatch - parameters supplied to the operation. +func (client ActionGroupsClient) Update(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch ActionGroupPatchBody) (result ActionGroupResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, actionGroupName, actionGroupPatch) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ActionGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch ActionGroupPatchBody) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", pathParameters), + autorest.WithJSON(actionGroupPatch), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) UpdateResponder(resp *http.Response) (result ActionGroupResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogalerts.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogalerts.go new file mode 100644 index 000000000000..f897b08a6f0c --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogalerts.go @@ -0,0 +1,545 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ActivityLogAlertsClient is the monitor Management Client +type ActivityLogAlertsClient struct { + BaseClient +} + +// NewActivityLogAlertsClient creates an instance of the ActivityLogAlertsClient client. +func NewActivityLogAlertsClient(subscriptionID string) ActivityLogAlertsClient { + return NewActivityLogAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewActivityLogAlertsClientWithBaseURI creates an instance of the ActivityLogAlertsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewActivityLogAlertsClientWithBaseURI(baseURI string, subscriptionID string) ActivityLogAlertsClient { + return ActivityLogAlertsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a new activity log alert or update an existing one. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// activityLogAlertName - the name of the activity log alert. +// activityLogAlert - the activity log alert to create or use for the update. +func (client ActivityLogAlertsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlert ActivityLogAlertResource) (result ActivityLogAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: activityLogAlert, + Constraints: []validation.Constraint{{Target: "activityLogAlert.ActivityLogAlert", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "activityLogAlert.ActivityLogAlert.Scopes", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "activityLogAlert.ActivityLogAlert.Condition", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "activityLogAlert.ActivityLogAlert.Condition.AllOf", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "activityLogAlert.ActivityLogAlert.Actions", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, activityLogAlertName, activityLogAlert) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ActivityLogAlertsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlert ActivityLogAlertResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", pathParameters), + autorest.WithJSON(activityLogAlert), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityLogAlertsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) CreateOrUpdateResponder(resp *http.Response) (result ActivityLogAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an activity log alert. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// activityLogAlertName - the name of the activity log alert. +func (client ActivityLogAlertsClient) Delete(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, activityLogAlertName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ActivityLogAlertsClient) DeletePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityLogAlertsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get an activity log alert. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// activityLogAlertName - the name of the activity log alert. +func (client ActivityLogAlertsClient) Get(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result ActivityLogAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, activityLogAlertName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ActivityLogAlertsClient) GetPreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityLogAlertsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) GetResponder(resp *http.Response) (result ActivityLogAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get a list of all activity log alerts in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ActivityLogAlertsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ActivityLogAlertList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ActivityLogAlertsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityLogAlertsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) ListByResourceGroupResponder(resp *http.Response) (result ActivityLogAlertList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscriptionID get a list of all activity log alerts in a subscription. +func (client ActivityLogAlertsClient) ListBySubscriptionID(ctx context.Context) (result ActivityLogAlertList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.ListBySubscriptionID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "ListBySubscriptionID", err.Error()) + } + + req, err := client.ListBySubscriptionIDPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListBySubscriptionID", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListBySubscriptionID", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListBySubscriptionID", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionIDPreparer prepares the ListBySubscriptionID request. +func (client ActivityLogAlertsClient) ListBySubscriptionIDPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionIDSender sends the ListBySubscriptionID request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityLogAlertsClient) ListBySubscriptionIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionIDResponder handles the response to the ListBySubscriptionID request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) ListBySubscriptionIDResponder(resp *http.Response) (result ActivityLogAlertList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// activityLogAlertName - the name of the activity log alert. +// activityLogAlertPatch - parameters supplied to the operation. +func (client ActivityLogAlertsClient) Update(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertPatch ActivityLogAlertPatchBody) (result ActivityLogAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, activityLogAlertName, activityLogAlertPatch) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ActivityLogAlertsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertPatch ActivityLogAlertPatchBody) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", pathParameters), + autorest.WithJSON(activityLogAlertPatch), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityLogAlertsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) UpdateResponder(resp *http.Response) (result ActivityLogAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogs.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogs.go new file mode 100644 index 000000000000..468cd15e3148 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogs.go @@ -0,0 +1,173 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ActivityLogsClient is the monitor Management Client +type ActivityLogsClient struct { + BaseClient +} + +// NewActivityLogsClient creates an instance of the ActivityLogsClient client. +func NewActivityLogsClient(subscriptionID string) ActivityLogsClient { + return NewActivityLogsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewActivityLogsClientWithBaseURI creates an instance of the ActivityLogsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewActivityLogsClientWithBaseURI(baseURI string, subscriptionID string) ActivityLogsClient { + return ActivityLogsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List provides the list of records from the activity logs. +// Parameters: +// filter - reduces the set of data collected.
This argument is required and it also requires at least the +// start date/time.
The **$filter** argument is very restricted and allows only the following patterns.
- +// *List events for a resource group*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and +// eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.
- *List +// events for resource*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le +// '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.
- *List events for a subscription in a +// time range*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le +// '2014-07-20T04:36:37.6407898Z'.
- *List events for a resource provider*: $filter=eventTimestamp ge +// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq +// 'resourceProviderName'.
- *List events for a correlation Id*: $filter=eventTimestamp ge +// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq +// 'correlationID'.

**NOTE**: No other syntax is allowed. +// selectParameter - used to fetch events with only the given properties.
The **$select** argument is a +// comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, +// *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, +// *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, +// *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* +func (client ActivityLogsClient) List(ctx context.Context, filter string, selectParameter string) (result EventDataCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogsClient.List") + defer func() { + sc := -1 + if result.edc.Response.Response != nil { + sc = result.edc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, filter, selectParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.edc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogsClient", "List", resp, "Failure sending request") + return + } + + result.edc, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogsClient", "List", resp, "Failure responding to request") + return + } + if result.edc.hasNextLink() && result.edc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ActivityLogsClient) ListPreparer(ctx context.Context, filter string, selectParameter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/eventtypes/management/values", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityLogsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ActivityLogsClient) ListResponder(resp *http.Response) (result EventDataCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ActivityLogsClient) listNextResults(ctx context.Context, lastResults EventDataCollection) (result EventDataCollection, err error) { + req, err := lastResults.eventDataCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.ActivityLogsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.ActivityLogsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ActivityLogsClient) ListComplete(ctx context.Context, filter string, selectParameter string) (result EventDataCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, filter, selectParameter) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertruleincidents.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertruleincidents.go new file mode 100644 index 000000000000..a7dcd9cba31e --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertruleincidents.go @@ -0,0 +1,205 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AlertRuleIncidentsClient is the monitor Management Client +type AlertRuleIncidentsClient struct { + BaseClient +} + +// NewAlertRuleIncidentsClient creates an instance of the AlertRuleIncidentsClient client. +func NewAlertRuleIncidentsClient(subscriptionID string) AlertRuleIncidentsClient { + return NewAlertRuleIncidentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAlertRuleIncidentsClientWithBaseURI creates an instance of the AlertRuleIncidentsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAlertRuleIncidentsClientWithBaseURI(baseURI string, subscriptionID string) AlertRuleIncidentsClient { + return AlertRuleIncidentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets an incident associated to an alert rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// incidentName - the name of the incident to retrieve. +func (client AlertRuleIncidentsClient) Get(ctx context.Context, resourceGroupName string, ruleName string, incidentName string) (result Incident, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRuleIncidentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRuleIncidentsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, ruleName, incidentName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AlertRuleIncidentsClient) GetPreparer(ctx context.Context, resourceGroupName string, ruleName string, incidentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "incidentName": autorest.Encode("path", incidentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRuleIncidentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AlertRuleIncidentsClient) GetResponder(resp *http.Response) (result Incident, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAlertRule gets a list of incidents associated to an alert rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client AlertRuleIncidentsClient) ListByAlertRule(ctx context.Context, resourceGroupName string, ruleName string) (result IncidentListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRuleIncidentsClient.ListByAlertRule") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRuleIncidentsClient", "ListByAlertRule", err.Error()) + } + + req, err := client.ListByAlertRulePreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAlertRuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", resp, "Failure sending request") + return + } + + result, err = client.ListByAlertRuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", resp, "Failure responding to request") + return + } + + return +} + +// ListByAlertRulePreparer prepares the ListByAlertRule request. +func (client AlertRuleIncidentsClient) ListByAlertRulePreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAlertRuleSender sends the ListByAlertRule request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRuleIncidentsClient) ListByAlertRuleSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAlertRuleResponder handles the response to the ListByAlertRule request. The method always +// closes the http.Response Body. +func (client AlertRuleIncidentsClient) ListByAlertRuleResponder(resp *http.Response) (result IncidentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertrules.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertrules.go new file mode 100644 index 000000000000..888ed122e267 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertrules.go @@ -0,0 +1,542 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AlertRulesClient is the monitor Management Client +type AlertRulesClient struct { + BaseClient +} + +// NewAlertRulesClient creates an instance of the AlertRulesClient client. +func NewAlertRulesClient(subscriptionID string) AlertRulesClient { + return NewAlertRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAlertRulesClientWithBaseURI creates an instance of the AlertRulesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAlertRulesClientWithBaseURI(baseURI string, subscriptionID string) AlertRulesClient { + return AlertRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a classic metric alert rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// parameters - the parameters of the rule to create or update. +func (client AlertRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters AlertRuleResource) (result AlertRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AlertRule", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AlertRule.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AlertRule.IsEnabled", Name: validation.Null, Rule: true, Chain: nil}, + }}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AlertRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters AlertRuleResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) CreateOrUpdateResponder(resp *http.Response) (result AlertRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a classic metric alert rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client AlertRulesClient) Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AlertRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a classic metric alert rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client AlertRulesClient) Get(ctx context.Context, resourceGroupName string, ruleName string) (result AlertRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AlertRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) GetResponder(resp *http.Response) (result AlertRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list the classic metric alert rules within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client AlertRulesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AlertRuleResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AlertRulesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) ListByResourceGroupResponder(resp *http.Response) (result AlertRuleResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription list the classic metric alert rules within a subscription. +func (client AlertRulesClient) ListBySubscription(ctx context.Context) (result AlertRuleResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client AlertRulesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) ListBySubscriptionResponder(resp *http.Response) (result AlertRuleResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// alertRulesResource - parameters supplied to the operation. +func (client AlertRulesClient) Update(ctx context.Context, resourceGroupName string, ruleName string, alertRulesResource AlertRuleResourcePatch) (result AlertRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, ruleName, alertRulesResource) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AlertRulesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, alertRulesResource AlertRuleResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", pathParameters), + autorest.WithJSON(alertRulesResource), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) UpdateResponder(resp *http.Response) (result AlertRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/autoscalesettings.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/autoscalesettings.go new file mode 100644 index 000000000000..db9b916df1d9 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/autoscalesettings.go @@ -0,0 +1,627 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AutoscaleSettingsClient is the monitor Management Client +type AutoscaleSettingsClient struct { + BaseClient +} + +// NewAutoscaleSettingsClient creates an instance of the AutoscaleSettingsClient client. +func NewAutoscaleSettingsClient(subscriptionID string) AutoscaleSettingsClient { + return NewAutoscaleSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAutoscaleSettingsClientWithBaseURI creates an instance of the AutoscaleSettingsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAutoscaleSettingsClientWithBaseURI(baseURI string, subscriptionID string) AutoscaleSettingsClient { + return AutoscaleSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an autoscale setting. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// autoscaleSettingName - the autoscale setting name. +// parameters - parameters supplied to the operation. +func (client AutoscaleSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource) (result AutoscaleSettingResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AutoscaleSetting", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AutoscaleSetting.Profiles", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AutoscaleSetting.Profiles", Name: validation.MaxItems, Rule: 20, Chain: nil}}}, + }}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, autoscaleSettingName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AutoscaleSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result AutoscaleSettingResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes and autoscale setting +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// autoscaleSettingName - the autoscale setting name. +func (client AutoscaleSettingsClient) Delete(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, autoscaleSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AutoscaleSettingsClient) DeletePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an autoscale setting +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// autoscaleSettingName - the autoscale setting name. +func (client AutoscaleSettingsClient) Get(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result AutoscaleSettingResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, autoscaleSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AutoscaleSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) GetResponder(resp *http.Response) (result AutoscaleSettingResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup lists the autoscale settings for a resource group +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client AutoscaleSettingsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AutoscaleSettingResourceCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.asrc.Response.Response != nil { + sc = result.asrc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.asrc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.asrc, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.asrc.hasNextLink() && result.asrc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AutoscaleSettingsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) ListByResourceGroupResponder(resp *http.Response) (result AutoscaleSettingResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client AutoscaleSettingsClient) listByResourceGroupNextResults(ctx context.Context, lastResults AutoscaleSettingResourceCollection) (result AutoscaleSettingResourceCollection, err error) { + req, err := lastResults.autoscaleSettingResourceCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client AutoscaleSettingsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AutoscaleSettingResourceCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription lists the autoscale settings for a subscription +func (client AutoscaleSettingsClient) ListBySubscription(ctx context.Context) (result AutoscaleSettingResourceCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListBySubscription") + defer func() { + sc := -1 + if result.asrc.Response.Response != nil { + sc = result.asrc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.asrc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.asrc, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.asrc.hasNextLink() && result.asrc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client AutoscaleSettingsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/autoscalesettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) ListBySubscriptionResponder(resp *http.Response) (result AutoscaleSettingResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client AutoscaleSettingsClient) listBySubscriptionNextResults(ctx context.Context, lastResults AutoscaleSettingResourceCollection) (result AutoscaleSettingResourceCollection, err error) { + req, err := lastResults.autoscaleSettingResourceCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client AutoscaleSettingsClient) ListBySubscriptionComplete(ctx context.Context) (result AutoscaleSettingResourceCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// Update updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// autoscaleSettingName - the autoscale setting name. +// autoscaleSettingResource - parameters supplied to the operation. +func (client AutoscaleSettingsClient) Update(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource AutoscaleSettingResourcePatch) (result AutoscaleSettingResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, autoscaleSettingName, autoscaleSettingResource) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AutoscaleSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource AutoscaleSettingResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}", pathParameters), + autorest.WithJSON(autoscaleSettingResource), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) UpdateResponder(resp *http.Response) (result AutoscaleSettingResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/baselines.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/baselines.go new file mode 100644 index 000000000000..337ce4d1fa0f --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/baselines.go @@ -0,0 +1,154 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// BaselinesClient is the monitor Management Client +type BaselinesClient struct { + BaseClient +} + +// NewBaselinesClient creates an instance of the BaselinesClient client. +func NewBaselinesClient(subscriptionID string) BaselinesClient { + return NewBaselinesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBaselinesClientWithBaseURI creates an instance of the BaselinesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewBaselinesClientWithBaseURI(baseURI string, subscriptionID string) BaselinesClient { + return BaselinesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List **Lists the metric baseline values for a resource**. +// Parameters: +// resourceURI - the identifier of the resource. +// metricnames - the names of the metrics (comma separated) to retrieve. Special case: If a metricname itself +// has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'** +// metricnamespace - metric namespace to query metric definitions for. +// timespan - the timespan of the query. It is a string with the following format +// 'startDateTime_ISO/endDateTime_ISO'. +// interval - the interval (i.e. timegrain) of the query. +// aggregation - the list of aggregation types (comma separated) to retrieve. +// sensitivities - the list of sensitivities (comma separated) to retrieve. +// filter - the **$filter** is used to reduce the set of metric data returned. Example: Metric contains +// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq 'a1' and B +// eq 'b1' or B eq 'b2' and C eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' or B = +// 'b2'** This is invalid because the logical or operator cannot separate two different metadata names. - +// Return all time series where A = a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - +// Return all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C eq '*'**. Special case: When +// dimension name or dimension value uses round brackets. Eg: When dimension name is **dim (test) 1** Instead +// of using $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' "** When dimension name +// is **dim (test) 3** and dimension value is **dim3 (test) val** Instead of using $filter= "dim (test) 3 eq +// 'dim3 (test) val' " use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "** +// resultType - allows retrieving only metadata of the baseline. On data request all information is retrieved. +func (client BaselinesClient) List(ctx context.Context, resourceURI string, metricnames string, metricnamespace string, timespan string, interval *string, aggregation string, sensitivities string, filter string, resultType ResultType) (result MetricBaselinesResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaselinesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.BaselinesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI, metricnames, metricnamespace, timespan, interval, aggregation, sensitivities, filter, resultType) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.BaselinesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.BaselinesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.BaselinesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client BaselinesClient) ListPreparer(ctx context.Context, resourceURI string, metricnames string, metricnamespace string, timespan string, interval *string, aggregation string, sensitivities string, filter string, resultType ResultType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2019-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(metricnames) > 0 { + queryParameters["metricnames"] = autorest.Encode("query", metricnames) + } + if len(metricnamespace) > 0 { + queryParameters["metricnamespace"] = autorest.Encode("query", metricnamespace) + } + if len(timespan) > 0 { + queryParameters["timespan"] = autorest.Encode("query", timespan) + } + if interval != nil { + queryParameters["interval"] = autorest.Encode("query", *interval) + } + if len(aggregation) > 0 { + queryParameters["aggregation"] = autorest.Encode("query", aggregation) + } + if len(sensitivities) > 0 { + queryParameters["sensitivities"] = autorest.Encode("query", sensitivities) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(string(resultType)) > 0 { + queryParameters["resultType"] = autorest.Encode("query", resultType) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/metricBaselines", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client BaselinesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client BaselinesClient) ListResponder(resp *http.Response) (result MetricBaselinesResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/client.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/client.go new file mode 100644 index 000000000000..a777181b0785 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/client.go @@ -0,0 +1,41 @@ +// Package insights implements the Azure ARM Insights service API version . +// +// Monitor Management Client +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Insights + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Insights. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionendpoints.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionendpoints.go new file mode 100644 index 000000000000..7369932edf27 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionendpoints.go @@ -0,0 +1,636 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DataCollectionEndpointsClient is the monitor Management Client +type DataCollectionEndpointsClient struct { + BaseClient +} + +// NewDataCollectionEndpointsClient creates an instance of the DataCollectionEndpointsClient client. +func NewDataCollectionEndpointsClient(subscriptionID string) DataCollectionEndpointsClient { + return NewDataCollectionEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataCollectionEndpointsClientWithBaseURI creates an instance of the DataCollectionEndpointsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewDataCollectionEndpointsClientWithBaseURI(baseURI string, subscriptionID string) DataCollectionEndpointsClient { + return DataCollectionEndpointsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create sends the create request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionEndpointName - the name of the data collection endpoint. The name is case insensitive. +// body - the payload +func (client DataCollectionEndpointsClient) Create(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *DataCollectionEndpointResource) (result DataCollectionEndpointResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Location", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, dataCollectionEndpointName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DataCollectionEndpointsClient) CreatePreparer(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *DataCollectionEndpointResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionEndpointName": autorest.Encode("path", dataCollectionEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + body.Etag = nil + body.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionEndpointsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) CreateResponder(resp *http.Response) (result DataCollectionEndpointResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionEndpointName - the name of the data collection endpoint. The name is case insensitive. +func (client DataCollectionEndpointsClient) Delete(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, dataCollectionEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DataCollectionEndpointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionEndpointName": autorest.Encode("path", dataCollectionEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionEndpointsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionEndpointName - the name of the data collection endpoint. The name is case insensitive. +func (client DataCollectionEndpointsClient) Get(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (result DataCollectionEndpointResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, dataCollectionEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DataCollectionEndpointsClient) GetPreparer(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionEndpointName": autorest.Encode("path", dataCollectionEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionEndpointsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) GetResponder(resp *http.Response) (result DataCollectionEndpointResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup sends the list by resource group request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client DataCollectionEndpointsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DataCollectionEndpointResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.dcerlr.Response.Response != nil { + sc = result.dcerlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.dcerlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.dcerlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.dcerlr.hasNextLink() && result.dcerlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client DataCollectionEndpointsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionEndpointsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) ListByResourceGroupResponder(resp *http.Response) (result DataCollectionEndpointResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client DataCollectionEndpointsClient) listByResourceGroupNextResults(ctx context.Context, lastResults DataCollectionEndpointResourceListResult) (result DataCollectionEndpointResourceListResult, err error) { + req, err := lastResults.dataCollectionEndpointResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionEndpointsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DataCollectionEndpointResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription sends the list by subscription request. +func (client DataCollectionEndpointsClient) ListBySubscription(ctx context.Context) (result DataCollectionEndpointResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.ListBySubscription") + defer func() { + sc := -1 + if result.dcerlr.Response.Response != nil { + sc = result.dcerlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.dcerlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.dcerlr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.dcerlr.hasNextLink() && result.dcerlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client DataCollectionEndpointsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionEndpointsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) ListBySubscriptionResponder(resp *http.Response) (result DataCollectionEndpointResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client DataCollectionEndpointsClient) listBySubscriptionNextResults(ctx context.Context, lastResults DataCollectionEndpointResourceListResult) (result DataCollectionEndpointResourceListResult, err error) { + req, err := lastResults.dataCollectionEndpointResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionEndpointsClient) ListBySubscriptionComplete(ctx context.Context) (result DataCollectionEndpointResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionEndpointName - the name of the data collection endpoint. The name is case insensitive. +// body - the payload +func (client DataCollectionEndpointsClient) Update(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *ResourceForUpdate) (result DataCollectionEndpointResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, dataCollectionEndpointName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DataCollectionEndpointsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *ResourceForUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionEndpointName": autorest.Encode("path", dataCollectionEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionEndpointsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) UpdateResponder(resp *http.Response) (result DataCollectionEndpointResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionruleassociations.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionruleassociations.go new file mode 100644 index 000000000000..59878dbc8c2f --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionruleassociations.go @@ -0,0 +1,534 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DataCollectionRuleAssociationsClient is the monitor Management Client +type DataCollectionRuleAssociationsClient struct { + BaseClient +} + +// NewDataCollectionRuleAssociationsClient creates an instance of the DataCollectionRuleAssociationsClient client. +func NewDataCollectionRuleAssociationsClient(subscriptionID string) DataCollectionRuleAssociationsClient { + return NewDataCollectionRuleAssociationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataCollectionRuleAssociationsClientWithBaseURI creates an instance of the DataCollectionRuleAssociationsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewDataCollectionRuleAssociationsClientWithBaseURI(baseURI string, subscriptionID string) DataCollectionRuleAssociationsClient { + return DataCollectionRuleAssociationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create sends the create request. +// Parameters: +// resourceURI - the identifier of the resource. +// associationName - the name of the association. The name is case insensitive. +// body - the payload +func (client DataCollectionRuleAssociationsClient) Create(ctx context.Context, resourceURI string, associationName string, body *DataCollectionRuleAssociationProxyOnlyResource) (result DataCollectionRuleAssociationProxyOnlyResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceURI, associationName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DataCollectionRuleAssociationsClient) CreatePreparer(ctx context.Context, resourceURI string, associationName string, body *DataCollectionRuleAssociationProxyOnlyResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "associationName": autorest.Encode("path", associationName), + "resourceUri": resourceURI, + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + body.Etag = nil + body.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRuleAssociationsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DataCollectionRuleAssociationsClient) CreateResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete sends the delete request. +// Parameters: +// resourceURI - the identifier of the resource. +// associationName - the name of the association. The name is case insensitive. +func (client DataCollectionRuleAssociationsClient) Delete(ctx context.Context, resourceURI string, associationName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceURI, associationName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DataCollectionRuleAssociationsClient) DeletePreparer(ctx context.Context, resourceURI string, associationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "associationName": autorest.Encode("path", associationName), + "resourceUri": resourceURI, + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRuleAssociationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DataCollectionRuleAssociationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceURI - the identifier of the resource. +// associationName - the name of the association. The name is case insensitive. +func (client DataCollectionRuleAssociationsClient) Get(ctx context.Context, resourceURI string, associationName string) (result DataCollectionRuleAssociationProxyOnlyResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceURI, associationName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DataCollectionRuleAssociationsClient) GetPreparer(ctx context.Context, resourceURI string, associationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "associationName": autorest.Encode("path", associationName), + "resourceUri": resourceURI, + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRuleAssociationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataCollectionRuleAssociationsClient) GetResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResource sends the list by resource request. +// Parameters: +// resourceURI - the identifier of the resource. +func (client DataCollectionRuleAssociationsClient) ListByResource(ctx context.Context, resourceURI string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByResource") + defer func() { + sc := -1 + if result.dcraporlr.Response.Response != nil { + sc = result.dcraporlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "ListByResource", err.Error()) + } + + result.fn = client.listByResourceNextResults + req, err := client.ListByResourcePreparer(ctx, resourceURI) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceSender(req) + if err != nil { + result.dcraporlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByResource", resp, "Failure sending request") + return + } + + result.dcraporlr, err = client.ListByResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByResource", resp, "Failure responding to request") + return + } + if result.dcraporlr.hasNextLink() && result.dcraporlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourcePreparer prepares the ListByResource request. +func (client DataCollectionRuleAssociationsClient) ListByResourcePreparer(ctx context.Context, resourceURI string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceSender sends the ListByResource request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRuleAssociationsClient) ListByResourceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByResourceResponder handles the response to the ListByResource request. The method always +// closes the http.Response Body. +func (client DataCollectionRuleAssociationsClient) ListByResourceResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceNextResults retrieves the next set of results, if any. +func (client DataCollectionRuleAssociationsClient) listByResourceNextResults(ctx context.Context, lastResults DataCollectionRuleAssociationProxyOnlyResourceListResult) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) { + req, err := lastResults.dataCollectionRuleAssociationProxyOnlyResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionRuleAssociationsClient) ListByResourceComplete(ctx context.Context, resourceURI string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByResource") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResource(ctx, resourceURI) + return +} + +// ListByRule sends the list by rule request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionRuleName - the name of the data collection rule. The name is case insensitive. +func (client DataCollectionRuleAssociationsClient) ListByRule(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByRule") + defer func() { + sc := -1 + if result.dcraporlr.Response.Response != nil { + sc = result.dcraporlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "ListByRule", err.Error()) + } + + result.fn = client.listByRuleNextResults + req, err := client.ListByRulePreparer(ctx, resourceGroupName, dataCollectionRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByRule", nil, "Failure preparing request") + return + } + + resp, err := client.ListByRuleSender(req) + if err != nil { + result.dcraporlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByRule", resp, "Failure sending request") + return + } + + result.dcraporlr, err = client.ListByRuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByRule", resp, "Failure responding to request") + return + } + if result.dcraporlr.hasNextLink() && result.dcraporlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByRulePreparer prepares the ListByRule request. +func (client DataCollectionRuleAssociationsClient) ListByRulePreparer(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionRuleName": autorest.Encode("path", dataCollectionRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByRuleSender sends the ListByRule request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRuleAssociationsClient) ListByRuleSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByRuleResponder handles the response to the ListByRule request. The method always +// closes the http.Response Body. +func (client DataCollectionRuleAssociationsClient) ListByRuleResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByRuleNextResults retrieves the next set of results, if any. +func (client DataCollectionRuleAssociationsClient) listByRuleNextResults(ctx context.Context, lastResults DataCollectionRuleAssociationProxyOnlyResourceListResult) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) { + req, err := lastResults.dataCollectionRuleAssociationProxyOnlyResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByRuleNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByRuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByRuleNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByRuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByRuleNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByRuleComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionRuleAssociationsClient) ListByRuleComplete(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByRule") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByRule(ctx, resourceGroupName, dataCollectionRuleName) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionrules.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionrules.go new file mode 100644 index 000000000000..e3baabf0f6b4 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionrules.go @@ -0,0 +1,636 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DataCollectionRulesClient is the monitor Management Client +type DataCollectionRulesClient struct { + BaseClient +} + +// NewDataCollectionRulesClient creates an instance of the DataCollectionRulesClient client. +func NewDataCollectionRulesClient(subscriptionID string) DataCollectionRulesClient { + return NewDataCollectionRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataCollectionRulesClientWithBaseURI creates an instance of the DataCollectionRulesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDataCollectionRulesClientWithBaseURI(baseURI string, subscriptionID string) DataCollectionRulesClient { + return DataCollectionRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create sends the create request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionRuleName - the name of the data collection rule. The name is case insensitive. +// body - the payload +func (client DataCollectionRulesClient) Create(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *DataCollectionRuleResource) (result DataCollectionRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Location", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, dataCollectionRuleName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DataCollectionRulesClient) CreatePreparer(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *DataCollectionRuleResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionRuleName": autorest.Encode("path", dataCollectionRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + body.Etag = nil + body.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRulesClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) CreateResponder(resp *http.Response) (result DataCollectionRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionRuleName - the name of the data collection rule. The name is case insensitive. +func (client DataCollectionRulesClient) Delete(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, dataCollectionRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DataCollectionRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionRuleName": autorest.Encode("path", dataCollectionRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionRuleName - the name of the data collection rule. The name is case insensitive. +func (client DataCollectionRulesClient) Get(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result DataCollectionRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, dataCollectionRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DataCollectionRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionRuleName": autorest.Encode("path", dataCollectionRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) GetResponder(resp *http.Response) (result DataCollectionRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup sends the list by resource group request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client DataCollectionRulesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DataCollectionRuleResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.dcrrlr.Response.Response != nil { + sc = result.dcrrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.dcrrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.dcrrlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.dcrrlr.hasNextLink() && result.dcrrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client DataCollectionRulesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRulesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) ListByResourceGroupResponder(resp *http.Response) (result DataCollectionRuleResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client DataCollectionRulesClient) listByResourceGroupNextResults(ctx context.Context, lastResults DataCollectionRuleResourceListResult) (result DataCollectionRuleResourceListResult, err error) { + req, err := lastResults.dataCollectionRuleResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionRulesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DataCollectionRuleResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription sends the list by subscription request. +func (client DataCollectionRulesClient) ListBySubscription(ctx context.Context) (result DataCollectionRuleResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.ListBySubscription") + defer func() { + sc := -1 + if result.dcrrlr.Response.Response != nil { + sc = result.dcrrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.dcrrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.dcrrlr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.dcrrlr.hasNextLink() && result.dcrrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client DataCollectionRulesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRulesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) ListBySubscriptionResponder(resp *http.Response) (result DataCollectionRuleResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client DataCollectionRulesClient) listBySubscriptionNextResults(ctx context.Context, lastResults DataCollectionRuleResourceListResult) (result DataCollectionRuleResourceListResult, err error) { + req, err := lastResults.dataCollectionRuleResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionRulesClient) ListBySubscriptionComplete(ctx context.Context) (result DataCollectionRuleResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionRuleName - the name of the data collection rule. The name is case insensitive. +// body - the payload +func (client DataCollectionRulesClient) Update(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *ResourceForUpdate) (result DataCollectionRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, dataCollectionRuleName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DataCollectionRulesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *ResourceForUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionRuleName": autorest.Encode("path", dataCollectionRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) UpdateResponder(resp *http.Response) (result DataCollectionRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettings.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettings.go new file mode 100644 index 000000000000..0c0ec82dfe29 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettings.go @@ -0,0 +1,357 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DiagnosticSettingsClient is the monitor Management Client +type DiagnosticSettingsClient struct { + BaseClient +} + +// NewDiagnosticSettingsClient creates an instance of the DiagnosticSettingsClient client. +func NewDiagnosticSettingsClient(subscriptionID string) DiagnosticSettingsClient { + return NewDiagnosticSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDiagnosticSettingsClientWithBaseURI creates an instance of the DiagnosticSettingsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDiagnosticSettingsClientWithBaseURI(baseURI string, subscriptionID string) DiagnosticSettingsClient { + return DiagnosticSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates diagnostic settings for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +// parameters - parameters supplied to the operation. +// name - the name of the diagnostic setting. +func (client DiagnosticSettingsClient) CreateOrUpdate(ctx context.Context, resourceURI string, parameters DiagnosticSettingsResource, name string) (result DiagnosticSettingsResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceURI, parameters, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DiagnosticSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceURI string, parameters DiagnosticSettingsResource, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": resourceURI, + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result DiagnosticSettingsResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes existing diagnostic settings for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +// name - the name of the diagnostic setting. +func (client DiagnosticSettingsClient) Delete(ctx context.Context, resourceURI string, name string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceURI, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DiagnosticSettingsClient) DeletePreparer(ctx context.Context, resourceURI string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": resourceURI, + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticSettingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the active diagnostic settings for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +// name - the name of the diagnostic setting. +func (client DiagnosticSettingsClient) Get(ctx context.Context, resourceURI string, name string) (result DiagnosticSettingsResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceURI, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DiagnosticSettingsClient) GetPreparer(ctx context.Context, resourceURI string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": resourceURI, + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsClient) GetResponder(resp *http.Response) (result DiagnosticSettingsResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the active diagnostic settings list for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +func (client DiagnosticSettingsClient) List(ctx context.Context, resourceURI string) (result DiagnosticSettingsResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DiagnosticSettingsClient) ListPreparer(ctx context.Context, resourceURI string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticSettingsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsClient) ListResponder(resp *http.Response) (result DiagnosticSettingsResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettingscategory.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettingscategory.go new file mode 100644 index 000000000000..bb7a66926c3e --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettingscategory.go @@ -0,0 +1,193 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DiagnosticSettingsCategoryClient is the monitor Management Client +type DiagnosticSettingsCategoryClient struct { + BaseClient +} + +// NewDiagnosticSettingsCategoryClient creates an instance of the DiagnosticSettingsCategoryClient client. +func NewDiagnosticSettingsCategoryClient(subscriptionID string) DiagnosticSettingsCategoryClient { + return NewDiagnosticSettingsCategoryClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDiagnosticSettingsCategoryClientWithBaseURI creates an instance of the DiagnosticSettingsCategoryClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewDiagnosticSettingsCategoryClientWithBaseURI(baseURI string, subscriptionID string) DiagnosticSettingsCategoryClient { + return DiagnosticSettingsCategoryClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the diagnostic settings category for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +// name - the name of the diagnostic setting. +func (client DiagnosticSettingsCategoryClient) Get(ctx context.Context, resourceURI string, name string) (result DiagnosticSettingsCategoryResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsCategoryClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsCategoryClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceURI, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DiagnosticSettingsCategoryClient) GetPreparer(ctx context.Context, resourceURI string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": resourceURI, + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettingsCategories/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticSettingsCategoryClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsCategoryClient) GetResponder(resp *http.Response) (result DiagnosticSettingsCategoryResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the diagnostic settings categories for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +func (client DiagnosticSettingsCategoryClient) List(ctx context.Context, resourceURI string) (result DiagnosticSettingsCategoryResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsCategoryClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsCategoryClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DiagnosticSettingsCategoryClient) ListPreparer(ctx context.Context, resourceURI string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettingsCategories", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DiagnosticSettingsCategoryClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsCategoryClient) ListResponder(resp *http.Response) (result DiagnosticSettingsCategoryResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/enums.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/enums.go new file mode 100644 index 000000000000..389d5ba71547 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/enums.go @@ -0,0 +1,968 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AggregationType enumerates the values for aggregation type. +type AggregationType string + +const ( + // Average ... + Average AggregationType = "Average" + // Count ... + Count AggregationType = "Count" + // Maximum ... + Maximum AggregationType = "Maximum" + // Minimum ... + Minimum AggregationType = "Minimum" + // None ... + None AggregationType = "None" + // Total ... + Total AggregationType = "Total" +) + +// PossibleAggregationTypeValues returns an array of possible values for the AggregationType const type. +func PossibleAggregationTypeValues() []AggregationType { + return []AggregationType{Average, Count, Maximum, Minimum, None, Total} +} + +// AggregationTypeEnum enumerates the values for aggregation type enum. +type AggregationTypeEnum string + +const ( + // AggregationTypeEnumAverage ... + AggregationTypeEnumAverage AggregationTypeEnum = "Average" + // AggregationTypeEnumCount ... + AggregationTypeEnumCount AggregationTypeEnum = "Count" + // AggregationTypeEnumMaximum ... + AggregationTypeEnumMaximum AggregationTypeEnum = "Maximum" + // AggregationTypeEnumMinimum ... + AggregationTypeEnumMinimum AggregationTypeEnum = "Minimum" + // AggregationTypeEnumTotal ... + AggregationTypeEnumTotal AggregationTypeEnum = "Total" +) + +// PossibleAggregationTypeEnumValues returns an array of possible values for the AggregationTypeEnum const type. +func PossibleAggregationTypeEnumValues() []AggregationTypeEnum { + return []AggregationTypeEnum{AggregationTypeEnumAverage, AggregationTypeEnumCount, AggregationTypeEnumMaximum, AggregationTypeEnumMinimum, AggregationTypeEnumTotal} +} + +// AlertSeverity enumerates the values for alert severity. +type AlertSeverity string + +const ( + // Four ... + Four AlertSeverity = "4" + // One ... + One AlertSeverity = "1" + // Three ... + Three AlertSeverity = "3" + // Two ... + Two AlertSeverity = "2" + // Zero ... + Zero AlertSeverity = "0" +) + +// PossibleAlertSeverityValues returns an array of possible values for the AlertSeverity const type. +func PossibleAlertSeverityValues() []AlertSeverity { + return []AlertSeverity{Four, One, Three, Two, Zero} +} + +// BaselineSensitivity enumerates the values for baseline sensitivity. +type BaselineSensitivity string + +const ( + // High ... + High BaselineSensitivity = "High" + // Low ... + Low BaselineSensitivity = "Low" + // Medium ... + Medium BaselineSensitivity = "Medium" +) + +// PossibleBaselineSensitivityValues returns an array of possible values for the BaselineSensitivity const type. +func PossibleBaselineSensitivityValues() []BaselineSensitivity { + return []BaselineSensitivity{High, Low, Medium} +} + +// CategoryType enumerates the values for category type. +type CategoryType string + +const ( + // Logs ... + Logs CategoryType = "Logs" + // Metrics ... + Metrics CategoryType = "Metrics" +) + +// PossibleCategoryTypeValues returns an array of possible values for the CategoryType const type. +func PossibleCategoryTypeValues() []CategoryType { + return []CategoryType{Logs, Metrics} +} + +// ComparisonOperationType enumerates the values for comparison operation type. +type ComparisonOperationType string + +const ( + // Equals ... + Equals ComparisonOperationType = "Equals" + // GreaterThan ... + GreaterThan ComparisonOperationType = "GreaterThan" + // GreaterThanOrEqual ... + GreaterThanOrEqual ComparisonOperationType = "GreaterThanOrEqual" + // LessThan ... + LessThan ComparisonOperationType = "LessThan" + // LessThanOrEqual ... + LessThanOrEqual ComparisonOperationType = "LessThanOrEqual" + // NotEquals ... + NotEquals ComparisonOperationType = "NotEquals" +) + +// PossibleComparisonOperationTypeValues returns an array of possible values for the ComparisonOperationType const type. +func PossibleComparisonOperationTypeValues() []ComparisonOperationType { + return []ComparisonOperationType{Equals, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, NotEquals} +} + +// ConditionalOperator enumerates the values for conditional operator. +type ConditionalOperator string + +const ( + // ConditionalOperatorEqual ... + ConditionalOperatorEqual ConditionalOperator = "Equal" + // ConditionalOperatorGreaterThan ... + ConditionalOperatorGreaterThan ConditionalOperator = "GreaterThan" + // ConditionalOperatorGreaterThanOrEqual ... + ConditionalOperatorGreaterThanOrEqual ConditionalOperator = "GreaterThanOrEqual" + // ConditionalOperatorLessThan ... + ConditionalOperatorLessThan ConditionalOperator = "LessThan" + // ConditionalOperatorLessThanOrEqual ... + ConditionalOperatorLessThanOrEqual ConditionalOperator = "LessThanOrEqual" +) + +// PossibleConditionalOperatorValues returns an array of possible values for the ConditionalOperator const type. +func PossibleConditionalOperatorValues() []ConditionalOperator { + return []ConditionalOperator{ConditionalOperatorEqual, ConditionalOperatorGreaterThan, ConditionalOperatorGreaterThanOrEqual, ConditionalOperatorLessThan, ConditionalOperatorLessThanOrEqual} +} + +// ConditionOperator enumerates the values for condition operator. +type ConditionOperator string + +const ( + // ConditionOperatorGreaterThan ... + ConditionOperatorGreaterThan ConditionOperator = "GreaterThan" + // ConditionOperatorGreaterThanOrEqual ... + ConditionOperatorGreaterThanOrEqual ConditionOperator = "GreaterThanOrEqual" + // ConditionOperatorLessThan ... + ConditionOperatorLessThan ConditionOperator = "LessThan" + // ConditionOperatorLessThanOrEqual ... + ConditionOperatorLessThanOrEqual ConditionOperator = "LessThanOrEqual" +) + +// PossibleConditionOperatorValues returns an array of possible values for the ConditionOperator const type. +func PossibleConditionOperatorValues() []ConditionOperator { + return []ConditionOperator{ConditionOperatorGreaterThan, ConditionOperatorGreaterThanOrEqual, ConditionOperatorLessThan, ConditionOperatorLessThanOrEqual} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// CriterionType enumerates the values for criterion type. +type CriterionType string + +const ( + // CriterionTypeDynamicThresholdCriterion ... + CriterionTypeDynamicThresholdCriterion CriterionType = "DynamicThresholdCriterion" + // CriterionTypeMultiMetricCriteria ... + CriterionTypeMultiMetricCriteria CriterionType = "MultiMetricCriteria" + // CriterionTypeStaticThresholdCriterion ... + CriterionTypeStaticThresholdCriterion CriterionType = "StaticThresholdCriterion" +) + +// PossibleCriterionTypeValues returns an array of possible values for the CriterionType const type. +func PossibleCriterionTypeValues() []CriterionType { + return []CriterionType{CriterionTypeDynamicThresholdCriterion, CriterionTypeMultiMetricCriteria, CriterionTypeStaticThresholdCriterion} +} + +// DataStatus enumerates the values for data status. +type DataStatus string + +const ( + // NotPresent ... + NotPresent DataStatus = "notPresent" + // Present ... + Present DataStatus = "present" +) + +// PossibleDataStatusValues returns an array of possible values for the DataStatus const type. +func PossibleDataStatusValues() []DataStatus { + return []DataStatus{NotPresent, Present} +} + +// DynamicThresholdOperator enumerates the values for dynamic threshold operator. +type DynamicThresholdOperator string + +const ( + // DynamicThresholdOperatorGreaterOrLessThan ... + DynamicThresholdOperatorGreaterOrLessThan DynamicThresholdOperator = "GreaterOrLessThan" + // DynamicThresholdOperatorGreaterThan ... + DynamicThresholdOperatorGreaterThan DynamicThresholdOperator = "GreaterThan" + // DynamicThresholdOperatorLessThan ... + DynamicThresholdOperatorLessThan DynamicThresholdOperator = "LessThan" +) + +// PossibleDynamicThresholdOperatorValues returns an array of possible values for the DynamicThresholdOperator const type. +func PossibleDynamicThresholdOperatorValues() []DynamicThresholdOperator { + return []DynamicThresholdOperator{DynamicThresholdOperatorGreaterOrLessThan, DynamicThresholdOperatorGreaterThan, DynamicThresholdOperatorLessThan} +} + +// DynamicThresholdSensitivity enumerates the values for dynamic threshold sensitivity. +type DynamicThresholdSensitivity string + +const ( + // DynamicThresholdSensitivityHigh ... + DynamicThresholdSensitivityHigh DynamicThresholdSensitivity = "High" + // DynamicThresholdSensitivityLow ... + DynamicThresholdSensitivityLow DynamicThresholdSensitivity = "Low" + // DynamicThresholdSensitivityMedium ... + DynamicThresholdSensitivityMedium DynamicThresholdSensitivity = "Medium" +) + +// PossibleDynamicThresholdSensitivityValues returns an array of possible values for the DynamicThresholdSensitivity const type. +func PossibleDynamicThresholdSensitivityValues() []DynamicThresholdSensitivity { + return []DynamicThresholdSensitivity{DynamicThresholdSensitivityHigh, DynamicThresholdSensitivityLow, DynamicThresholdSensitivityMedium} +} + +// Enabled enumerates the values for enabled. +type Enabled string + +const ( + // False ... + False Enabled = "false" + // True ... + True Enabled = "true" +) + +// PossibleEnabledValues returns an array of possible values for the Enabled const type. +func PossibleEnabledValues() []Enabled { + return []Enabled{False, True} +} + +// EventLevel enumerates the values for event level. +type EventLevel string + +const ( + // EventLevelCritical ... + EventLevelCritical EventLevel = "Critical" + // EventLevelError ... + EventLevelError EventLevel = "Error" + // EventLevelInformational ... + EventLevelInformational EventLevel = "Informational" + // EventLevelVerbose ... + EventLevelVerbose EventLevel = "Verbose" + // EventLevelWarning ... + EventLevelWarning EventLevel = "Warning" +) + +// PossibleEventLevelValues returns an array of possible values for the EventLevel const type. +func PossibleEventLevelValues() []EventLevel { + return []EventLevel{EventLevelCritical, EventLevelError, EventLevelInformational, EventLevelVerbose, EventLevelWarning} +} + +// KnownDataCollectionEndpointProvisioningState enumerates the values for known data collection endpoint +// provisioning state. +type KnownDataCollectionEndpointProvisioningState string + +const ( + // Creating ... + Creating KnownDataCollectionEndpointProvisioningState = "Creating" + // Deleting ... + Deleting KnownDataCollectionEndpointProvisioningState = "Deleting" + // Failed ... + Failed KnownDataCollectionEndpointProvisioningState = "Failed" + // Succeeded ... + Succeeded KnownDataCollectionEndpointProvisioningState = "Succeeded" + // Updating ... + Updating KnownDataCollectionEndpointProvisioningState = "Updating" +) + +// PossibleKnownDataCollectionEndpointProvisioningStateValues returns an array of possible values for the KnownDataCollectionEndpointProvisioningState const type. +func PossibleKnownDataCollectionEndpointProvisioningStateValues() []KnownDataCollectionEndpointProvisioningState { + return []KnownDataCollectionEndpointProvisioningState{Creating, Deleting, Failed, Succeeded, Updating} +} + +// KnownDataCollectionEndpointResourceKind enumerates the values for known data collection endpoint resource +// kind. +type KnownDataCollectionEndpointResourceKind string + +const ( + // Linux ... + Linux KnownDataCollectionEndpointResourceKind = "Linux" + // Windows ... + Windows KnownDataCollectionEndpointResourceKind = "Windows" +) + +// PossibleKnownDataCollectionEndpointResourceKindValues returns an array of possible values for the KnownDataCollectionEndpointResourceKind const type. +func PossibleKnownDataCollectionEndpointResourceKindValues() []KnownDataCollectionEndpointResourceKind { + return []KnownDataCollectionEndpointResourceKind{Linux, Windows} +} + +// KnownDataCollectionRuleAssociationProvisioningState enumerates the values for known data collection rule +// association provisioning state. +type KnownDataCollectionRuleAssociationProvisioningState string + +const ( + // KnownDataCollectionRuleAssociationProvisioningStateCreating ... + KnownDataCollectionRuleAssociationProvisioningStateCreating KnownDataCollectionRuleAssociationProvisioningState = "Creating" + // KnownDataCollectionRuleAssociationProvisioningStateDeleting ... + KnownDataCollectionRuleAssociationProvisioningStateDeleting KnownDataCollectionRuleAssociationProvisioningState = "Deleting" + // KnownDataCollectionRuleAssociationProvisioningStateFailed ... + KnownDataCollectionRuleAssociationProvisioningStateFailed KnownDataCollectionRuleAssociationProvisioningState = "Failed" + // KnownDataCollectionRuleAssociationProvisioningStateSucceeded ... + KnownDataCollectionRuleAssociationProvisioningStateSucceeded KnownDataCollectionRuleAssociationProvisioningState = "Succeeded" + // KnownDataCollectionRuleAssociationProvisioningStateUpdating ... + KnownDataCollectionRuleAssociationProvisioningStateUpdating KnownDataCollectionRuleAssociationProvisioningState = "Updating" +) + +// PossibleKnownDataCollectionRuleAssociationProvisioningStateValues returns an array of possible values for the KnownDataCollectionRuleAssociationProvisioningState const type. +func PossibleKnownDataCollectionRuleAssociationProvisioningStateValues() []KnownDataCollectionRuleAssociationProvisioningState { + return []KnownDataCollectionRuleAssociationProvisioningState{KnownDataCollectionRuleAssociationProvisioningStateCreating, KnownDataCollectionRuleAssociationProvisioningStateDeleting, KnownDataCollectionRuleAssociationProvisioningStateFailed, KnownDataCollectionRuleAssociationProvisioningStateSucceeded, KnownDataCollectionRuleAssociationProvisioningStateUpdating} +} + +// KnownDataCollectionRuleProvisioningState enumerates the values for known data collection rule provisioning +// state. +type KnownDataCollectionRuleProvisioningState string + +const ( + // KnownDataCollectionRuleProvisioningStateCreating ... + KnownDataCollectionRuleProvisioningStateCreating KnownDataCollectionRuleProvisioningState = "Creating" + // KnownDataCollectionRuleProvisioningStateDeleting ... + KnownDataCollectionRuleProvisioningStateDeleting KnownDataCollectionRuleProvisioningState = "Deleting" + // KnownDataCollectionRuleProvisioningStateFailed ... + KnownDataCollectionRuleProvisioningStateFailed KnownDataCollectionRuleProvisioningState = "Failed" + // KnownDataCollectionRuleProvisioningStateSucceeded ... + KnownDataCollectionRuleProvisioningStateSucceeded KnownDataCollectionRuleProvisioningState = "Succeeded" + // KnownDataCollectionRuleProvisioningStateUpdating ... + KnownDataCollectionRuleProvisioningStateUpdating KnownDataCollectionRuleProvisioningState = "Updating" +) + +// PossibleKnownDataCollectionRuleProvisioningStateValues returns an array of possible values for the KnownDataCollectionRuleProvisioningState const type. +func PossibleKnownDataCollectionRuleProvisioningStateValues() []KnownDataCollectionRuleProvisioningState { + return []KnownDataCollectionRuleProvisioningState{KnownDataCollectionRuleProvisioningStateCreating, KnownDataCollectionRuleProvisioningStateDeleting, KnownDataCollectionRuleProvisioningStateFailed, KnownDataCollectionRuleProvisioningStateSucceeded, KnownDataCollectionRuleProvisioningStateUpdating} +} + +// KnownDataCollectionRuleResourceKind enumerates the values for known data collection rule resource kind. +type KnownDataCollectionRuleResourceKind string + +const ( + // KnownDataCollectionRuleResourceKindLinux ... + KnownDataCollectionRuleResourceKindLinux KnownDataCollectionRuleResourceKind = "Linux" + // KnownDataCollectionRuleResourceKindWindows ... + KnownDataCollectionRuleResourceKindWindows KnownDataCollectionRuleResourceKind = "Windows" +) + +// PossibleKnownDataCollectionRuleResourceKindValues returns an array of possible values for the KnownDataCollectionRuleResourceKind const type. +func PossibleKnownDataCollectionRuleResourceKindValues() []KnownDataCollectionRuleResourceKind { + return []KnownDataCollectionRuleResourceKind{KnownDataCollectionRuleResourceKindLinux, KnownDataCollectionRuleResourceKindWindows} +} + +// KnownDataFlowStreams enumerates the values for known data flow streams. +type KnownDataFlowStreams string + +const ( + // MicrosoftEvent ... + MicrosoftEvent KnownDataFlowStreams = "Microsoft-Event" + // MicrosoftInsightsMetrics ... + MicrosoftInsightsMetrics KnownDataFlowStreams = "Microsoft-InsightsMetrics" + // MicrosoftPerf ... + MicrosoftPerf KnownDataFlowStreams = "Microsoft-Perf" + // MicrosoftSyslog ... + MicrosoftSyslog KnownDataFlowStreams = "Microsoft-Syslog" + // MicrosoftWindowsEvent ... + MicrosoftWindowsEvent KnownDataFlowStreams = "Microsoft-WindowsEvent" +) + +// PossibleKnownDataFlowStreamsValues returns an array of possible values for the KnownDataFlowStreams const type. +func PossibleKnownDataFlowStreamsValues() []KnownDataFlowStreams { + return []KnownDataFlowStreams{MicrosoftEvent, MicrosoftInsightsMetrics, MicrosoftPerf, MicrosoftSyslog, MicrosoftWindowsEvent} +} + +// KnownExtensionDataSourceStreams enumerates the values for known extension data source streams. +type KnownExtensionDataSourceStreams string + +const ( + // KnownExtensionDataSourceStreamsMicrosoftEvent ... + KnownExtensionDataSourceStreamsMicrosoftEvent KnownExtensionDataSourceStreams = "Microsoft-Event" + // KnownExtensionDataSourceStreamsMicrosoftInsightsMetrics ... + KnownExtensionDataSourceStreamsMicrosoftInsightsMetrics KnownExtensionDataSourceStreams = "Microsoft-InsightsMetrics" + // KnownExtensionDataSourceStreamsMicrosoftPerf ... + KnownExtensionDataSourceStreamsMicrosoftPerf KnownExtensionDataSourceStreams = "Microsoft-Perf" + // KnownExtensionDataSourceStreamsMicrosoftSyslog ... + KnownExtensionDataSourceStreamsMicrosoftSyslog KnownExtensionDataSourceStreams = "Microsoft-Syslog" + // KnownExtensionDataSourceStreamsMicrosoftWindowsEvent ... + KnownExtensionDataSourceStreamsMicrosoftWindowsEvent KnownExtensionDataSourceStreams = "Microsoft-WindowsEvent" +) + +// PossibleKnownExtensionDataSourceStreamsValues returns an array of possible values for the KnownExtensionDataSourceStreams const type. +func PossibleKnownExtensionDataSourceStreamsValues() []KnownExtensionDataSourceStreams { + return []KnownExtensionDataSourceStreams{KnownExtensionDataSourceStreamsMicrosoftEvent, KnownExtensionDataSourceStreamsMicrosoftInsightsMetrics, KnownExtensionDataSourceStreamsMicrosoftPerf, KnownExtensionDataSourceStreamsMicrosoftSyslog, KnownExtensionDataSourceStreamsMicrosoftWindowsEvent} +} + +// KnownPerfCounterDataSourceStreams enumerates the values for known perf counter data source streams. +type KnownPerfCounterDataSourceStreams string + +const ( + // KnownPerfCounterDataSourceStreamsMicrosoftInsightsMetrics ... + KnownPerfCounterDataSourceStreamsMicrosoftInsightsMetrics KnownPerfCounterDataSourceStreams = "Microsoft-InsightsMetrics" + // KnownPerfCounterDataSourceStreamsMicrosoftPerf ... + KnownPerfCounterDataSourceStreamsMicrosoftPerf KnownPerfCounterDataSourceStreams = "Microsoft-Perf" +) + +// PossibleKnownPerfCounterDataSourceStreamsValues returns an array of possible values for the KnownPerfCounterDataSourceStreams const type. +func PossibleKnownPerfCounterDataSourceStreamsValues() []KnownPerfCounterDataSourceStreams { + return []KnownPerfCounterDataSourceStreams{KnownPerfCounterDataSourceStreamsMicrosoftInsightsMetrics, KnownPerfCounterDataSourceStreamsMicrosoftPerf} +} + +// KnownPublicNetworkAccessOptions enumerates the values for known public network access options. +type KnownPublicNetworkAccessOptions string + +const ( + // KnownPublicNetworkAccessOptionsDisabled ... + KnownPublicNetworkAccessOptionsDisabled KnownPublicNetworkAccessOptions = "Disabled" + // KnownPublicNetworkAccessOptionsEnabled ... + KnownPublicNetworkAccessOptionsEnabled KnownPublicNetworkAccessOptions = "Enabled" +) + +// PossibleKnownPublicNetworkAccessOptionsValues returns an array of possible values for the KnownPublicNetworkAccessOptions const type. +func PossibleKnownPublicNetworkAccessOptionsValues() []KnownPublicNetworkAccessOptions { + return []KnownPublicNetworkAccessOptions{KnownPublicNetworkAccessOptionsDisabled, KnownPublicNetworkAccessOptionsEnabled} +} + +// KnownSyslogDataSourceFacilityNames enumerates the values for known syslog data source facility names. +type KnownSyslogDataSourceFacilityNames string + +const ( + // KnownSyslogDataSourceFacilityNamesAsterisk ... + KnownSyslogDataSourceFacilityNamesAsterisk KnownSyslogDataSourceFacilityNames = "*" + // KnownSyslogDataSourceFacilityNamesAuth ... + KnownSyslogDataSourceFacilityNamesAuth KnownSyslogDataSourceFacilityNames = "auth" + // KnownSyslogDataSourceFacilityNamesAuthpriv ... + KnownSyslogDataSourceFacilityNamesAuthpriv KnownSyslogDataSourceFacilityNames = "authpriv" + // KnownSyslogDataSourceFacilityNamesCron ... + KnownSyslogDataSourceFacilityNamesCron KnownSyslogDataSourceFacilityNames = "cron" + // KnownSyslogDataSourceFacilityNamesDaemon ... + KnownSyslogDataSourceFacilityNamesDaemon KnownSyslogDataSourceFacilityNames = "daemon" + // KnownSyslogDataSourceFacilityNamesKern ... + KnownSyslogDataSourceFacilityNamesKern KnownSyslogDataSourceFacilityNames = "kern" + // KnownSyslogDataSourceFacilityNamesLocal0 ... + KnownSyslogDataSourceFacilityNamesLocal0 KnownSyslogDataSourceFacilityNames = "local0" + // KnownSyslogDataSourceFacilityNamesLocal1 ... + KnownSyslogDataSourceFacilityNamesLocal1 KnownSyslogDataSourceFacilityNames = "local1" + // KnownSyslogDataSourceFacilityNamesLocal2 ... + KnownSyslogDataSourceFacilityNamesLocal2 KnownSyslogDataSourceFacilityNames = "local2" + // KnownSyslogDataSourceFacilityNamesLocal3 ... + KnownSyslogDataSourceFacilityNamesLocal3 KnownSyslogDataSourceFacilityNames = "local3" + // KnownSyslogDataSourceFacilityNamesLocal4 ... + KnownSyslogDataSourceFacilityNamesLocal4 KnownSyslogDataSourceFacilityNames = "local4" + // KnownSyslogDataSourceFacilityNamesLocal5 ... + KnownSyslogDataSourceFacilityNamesLocal5 KnownSyslogDataSourceFacilityNames = "local5" + // KnownSyslogDataSourceFacilityNamesLocal6 ... + KnownSyslogDataSourceFacilityNamesLocal6 KnownSyslogDataSourceFacilityNames = "local6" + // KnownSyslogDataSourceFacilityNamesLocal7 ... + KnownSyslogDataSourceFacilityNamesLocal7 KnownSyslogDataSourceFacilityNames = "local7" + // KnownSyslogDataSourceFacilityNamesLpr ... + KnownSyslogDataSourceFacilityNamesLpr KnownSyslogDataSourceFacilityNames = "lpr" + // KnownSyslogDataSourceFacilityNamesMail ... + KnownSyslogDataSourceFacilityNamesMail KnownSyslogDataSourceFacilityNames = "mail" + // KnownSyslogDataSourceFacilityNamesMark ... + KnownSyslogDataSourceFacilityNamesMark KnownSyslogDataSourceFacilityNames = "mark" + // KnownSyslogDataSourceFacilityNamesNews ... + KnownSyslogDataSourceFacilityNamesNews KnownSyslogDataSourceFacilityNames = "news" + // KnownSyslogDataSourceFacilityNamesSyslog ... + KnownSyslogDataSourceFacilityNamesSyslog KnownSyslogDataSourceFacilityNames = "syslog" + // KnownSyslogDataSourceFacilityNamesUser ... + KnownSyslogDataSourceFacilityNamesUser KnownSyslogDataSourceFacilityNames = "user" + // KnownSyslogDataSourceFacilityNamesUucp ... + KnownSyslogDataSourceFacilityNamesUucp KnownSyslogDataSourceFacilityNames = "uucp" +) + +// PossibleKnownSyslogDataSourceFacilityNamesValues returns an array of possible values for the KnownSyslogDataSourceFacilityNames const type. +func PossibleKnownSyslogDataSourceFacilityNamesValues() []KnownSyslogDataSourceFacilityNames { + return []KnownSyslogDataSourceFacilityNames{KnownSyslogDataSourceFacilityNamesAsterisk, KnownSyslogDataSourceFacilityNamesAuth, KnownSyslogDataSourceFacilityNamesAuthpriv, KnownSyslogDataSourceFacilityNamesCron, KnownSyslogDataSourceFacilityNamesDaemon, KnownSyslogDataSourceFacilityNamesKern, KnownSyslogDataSourceFacilityNamesLocal0, KnownSyslogDataSourceFacilityNamesLocal1, KnownSyslogDataSourceFacilityNamesLocal2, KnownSyslogDataSourceFacilityNamesLocal3, KnownSyslogDataSourceFacilityNamesLocal4, KnownSyslogDataSourceFacilityNamesLocal5, KnownSyslogDataSourceFacilityNamesLocal6, KnownSyslogDataSourceFacilityNamesLocal7, KnownSyslogDataSourceFacilityNamesLpr, KnownSyslogDataSourceFacilityNamesMail, KnownSyslogDataSourceFacilityNamesMark, KnownSyslogDataSourceFacilityNamesNews, KnownSyslogDataSourceFacilityNamesSyslog, KnownSyslogDataSourceFacilityNamesUser, KnownSyslogDataSourceFacilityNamesUucp} +} + +// KnownSyslogDataSourceLogLevels enumerates the values for known syslog data source log levels. +type KnownSyslogDataSourceLogLevels string + +const ( + // KnownSyslogDataSourceLogLevelsAlert ... + KnownSyslogDataSourceLogLevelsAlert KnownSyslogDataSourceLogLevels = "Alert" + // KnownSyslogDataSourceLogLevelsAsterisk ... + KnownSyslogDataSourceLogLevelsAsterisk KnownSyslogDataSourceLogLevels = "*" + // KnownSyslogDataSourceLogLevelsCritical ... + KnownSyslogDataSourceLogLevelsCritical KnownSyslogDataSourceLogLevels = "Critical" + // KnownSyslogDataSourceLogLevelsDebug ... + KnownSyslogDataSourceLogLevelsDebug KnownSyslogDataSourceLogLevels = "Debug" + // KnownSyslogDataSourceLogLevelsEmergency ... + KnownSyslogDataSourceLogLevelsEmergency KnownSyslogDataSourceLogLevels = "Emergency" + // KnownSyslogDataSourceLogLevelsError ... + KnownSyslogDataSourceLogLevelsError KnownSyslogDataSourceLogLevels = "Error" + // KnownSyslogDataSourceLogLevelsInfo ... + KnownSyslogDataSourceLogLevelsInfo KnownSyslogDataSourceLogLevels = "Info" + // KnownSyslogDataSourceLogLevelsNotice ... + KnownSyslogDataSourceLogLevelsNotice KnownSyslogDataSourceLogLevels = "Notice" + // KnownSyslogDataSourceLogLevelsWarning ... + KnownSyslogDataSourceLogLevelsWarning KnownSyslogDataSourceLogLevels = "Warning" +) + +// PossibleKnownSyslogDataSourceLogLevelsValues returns an array of possible values for the KnownSyslogDataSourceLogLevels const type. +func PossibleKnownSyslogDataSourceLogLevelsValues() []KnownSyslogDataSourceLogLevels { + return []KnownSyslogDataSourceLogLevels{KnownSyslogDataSourceLogLevelsAlert, KnownSyslogDataSourceLogLevelsAsterisk, KnownSyslogDataSourceLogLevelsCritical, KnownSyslogDataSourceLogLevelsDebug, KnownSyslogDataSourceLogLevelsEmergency, KnownSyslogDataSourceLogLevelsError, KnownSyslogDataSourceLogLevelsInfo, KnownSyslogDataSourceLogLevelsNotice, KnownSyslogDataSourceLogLevelsWarning} +} + +// KnownSyslogDataSourceStreams enumerates the values for known syslog data source streams. +type KnownSyslogDataSourceStreams string + +const ( + // KnownSyslogDataSourceStreamsMicrosoftSyslog ... + KnownSyslogDataSourceStreamsMicrosoftSyslog KnownSyslogDataSourceStreams = "Microsoft-Syslog" +) + +// PossibleKnownSyslogDataSourceStreamsValues returns an array of possible values for the KnownSyslogDataSourceStreams const type. +func PossibleKnownSyslogDataSourceStreamsValues() []KnownSyslogDataSourceStreams { + return []KnownSyslogDataSourceStreams{KnownSyslogDataSourceStreamsMicrosoftSyslog} +} + +// KnownWindowsEventLogDataSourceStreams enumerates the values for known windows event log data source streams. +type KnownWindowsEventLogDataSourceStreams string + +const ( + // KnownWindowsEventLogDataSourceStreamsMicrosoftEvent ... + KnownWindowsEventLogDataSourceStreamsMicrosoftEvent KnownWindowsEventLogDataSourceStreams = "Microsoft-Event" + // KnownWindowsEventLogDataSourceStreamsMicrosoftWindowsEvent ... + KnownWindowsEventLogDataSourceStreamsMicrosoftWindowsEvent KnownWindowsEventLogDataSourceStreams = "Microsoft-WindowsEvent" +) + +// PossibleKnownWindowsEventLogDataSourceStreamsValues returns an array of possible values for the KnownWindowsEventLogDataSourceStreams const type. +func PossibleKnownWindowsEventLogDataSourceStreamsValues() []KnownWindowsEventLogDataSourceStreams { + return []KnownWindowsEventLogDataSourceStreams{KnownWindowsEventLogDataSourceStreamsMicrosoftEvent, KnownWindowsEventLogDataSourceStreamsMicrosoftWindowsEvent} +} + +// MetricStatisticType enumerates the values for metric statistic type. +type MetricStatisticType string + +const ( + // MetricStatisticTypeAverage ... + MetricStatisticTypeAverage MetricStatisticType = "Average" + // MetricStatisticTypeMax ... + MetricStatisticTypeMax MetricStatisticType = "Max" + // MetricStatisticTypeMin ... + MetricStatisticTypeMin MetricStatisticType = "Min" + // MetricStatisticTypeSum ... + MetricStatisticTypeSum MetricStatisticType = "Sum" +) + +// PossibleMetricStatisticTypeValues returns an array of possible values for the MetricStatisticType const type. +func PossibleMetricStatisticTypeValues() []MetricStatisticType { + return []MetricStatisticType{MetricStatisticTypeAverage, MetricStatisticTypeMax, MetricStatisticTypeMin, MetricStatisticTypeSum} +} + +// MetricTriggerType enumerates the values for metric trigger type. +type MetricTriggerType string + +const ( + // MetricTriggerTypeConsecutive ... + MetricTriggerTypeConsecutive MetricTriggerType = "Consecutive" + // MetricTriggerTypeTotal ... + MetricTriggerTypeTotal MetricTriggerType = "Total" +) + +// PossibleMetricTriggerTypeValues returns an array of possible values for the MetricTriggerType const type. +func PossibleMetricTriggerTypeValues() []MetricTriggerType { + return []MetricTriggerType{MetricTriggerTypeConsecutive, MetricTriggerTypeTotal} +} + +// MetricUnit enumerates the values for metric unit. +type MetricUnit string + +const ( + // MetricUnitBitsPerSecond ... + MetricUnitBitsPerSecond MetricUnit = "BitsPerSecond" + // MetricUnitBytes ... + MetricUnitBytes MetricUnit = "Bytes" + // MetricUnitByteSeconds ... + MetricUnitByteSeconds MetricUnit = "ByteSeconds" + // MetricUnitBytesPerSecond ... + MetricUnitBytesPerSecond MetricUnit = "BytesPerSecond" + // MetricUnitCores ... + MetricUnitCores MetricUnit = "Cores" + // MetricUnitCount ... + MetricUnitCount MetricUnit = "Count" + // MetricUnitCountPerSecond ... + MetricUnitCountPerSecond MetricUnit = "CountPerSecond" + // MetricUnitMilliCores ... + MetricUnitMilliCores MetricUnit = "MilliCores" + // MetricUnitMilliSeconds ... + MetricUnitMilliSeconds MetricUnit = "MilliSeconds" + // MetricUnitNanoCores ... + MetricUnitNanoCores MetricUnit = "NanoCores" + // MetricUnitPercent ... + MetricUnitPercent MetricUnit = "Percent" + // MetricUnitSeconds ... + MetricUnitSeconds MetricUnit = "Seconds" + // MetricUnitUnspecified ... + MetricUnitUnspecified MetricUnit = "Unspecified" +) + +// PossibleMetricUnitValues returns an array of possible values for the MetricUnit const type. +func PossibleMetricUnitValues() []MetricUnit { + return []MetricUnit{MetricUnitBitsPerSecond, MetricUnitBytes, MetricUnitByteSeconds, MetricUnitBytesPerSecond, MetricUnitCores, MetricUnitCount, MetricUnitCountPerSecond, MetricUnitMilliCores, MetricUnitMilliSeconds, MetricUnitNanoCores, MetricUnitPercent, MetricUnitSeconds, MetricUnitUnspecified} +} + +// NamespaceClassification enumerates the values for namespace classification. +type NamespaceClassification string + +const ( + // Custom ... + Custom NamespaceClassification = "Custom" + // Platform ... + Platform NamespaceClassification = "Platform" + // Qos ... + Qos NamespaceClassification = "Qos" +) + +// PossibleNamespaceClassificationValues returns an array of possible values for the NamespaceClassification const type. +func PossibleNamespaceClassificationValues() []NamespaceClassification { + return []NamespaceClassification{Custom, Platform, Qos} +} + +// OdataType enumerates the values for odata type. +type OdataType string + +const ( + // OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource ... + OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource OdataType = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" + // OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource ... + OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource OdataType = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" + // OdataTypeRuleDataSource ... + OdataTypeRuleDataSource OdataType = "RuleDataSource" +) + +// PossibleOdataTypeValues returns an array of possible values for the OdataType const type. +func PossibleOdataTypeValues() []OdataType { + return []OdataType{OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource, OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource, OdataTypeRuleDataSource} +} + +// OdataTypeBasicAction enumerates the values for odata type basic action. +type OdataTypeBasicAction string + +const ( + // OdataTypeAction ... + OdataTypeAction OdataTypeBasicAction = "Action" + // OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction ... + OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction OdataTypeBasicAction = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction" + // OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction ... + OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction OdataTypeBasicAction = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction" +) + +// PossibleOdataTypeBasicActionValues returns an array of possible values for the OdataTypeBasicAction const type. +func PossibleOdataTypeBasicActionValues() []OdataTypeBasicAction { + return []OdataTypeBasicAction{OdataTypeAction, OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction, OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction} +} + +// OdataTypeBasicMetricAlertCriteria enumerates the values for odata type basic metric alert criteria. +type OdataTypeBasicMetricAlertCriteria string + +const ( + // OdataTypeMetricAlertCriteria ... + OdataTypeMetricAlertCriteria OdataTypeBasicMetricAlertCriteria = "MetricAlertCriteria" + // OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria ... + OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria OdataTypeBasicMetricAlertCriteria = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" + // OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria ... + OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria OdataTypeBasicMetricAlertCriteria = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" + // OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria ... + OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria OdataTypeBasicMetricAlertCriteria = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" +) + +// PossibleOdataTypeBasicMetricAlertCriteriaValues returns an array of possible values for the OdataTypeBasicMetricAlertCriteria const type. +func PossibleOdataTypeBasicMetricAlertCriteriaValues() []OdataTypeBasicMetricAlertCriteria { + return []OdataTypeBasicMetricAlertCriteria{OdataTypeMetricAlertCriteria, OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria, OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria, OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria} +} + +// OdataTypeBasicRuleAction enumerates the values for odata type basic rule action. +type OdataTypeBasicRuleAction string + +const ( + // OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction ... + OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction OdataTypeBasicRuleAction = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" + // OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction ... + OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction OdataTypeBasicRuleAction = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" + // OdataTypeRuleAction ... + OdataTypeRuleAction OdataTypeBasicRuleAction = "RuleAction" +) + +// PossibleOdataTypeBasicRuleActionValues returns an array of possible values for the OdataTypeBasicRuleAction const type. +func PossibleOdataTypeBasicRuleActionValues() []OdataTypeBasicRuleAction { + return []OdataTypeBasicRuleAction{OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction, OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction, OdataTypeRuleAction} +} + +// OdataTypeBasicRuleCondition enumerates the values for odata type basic rule condition. +type OdataTypeBasicRuleCondition string + +const ( + // OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition ... + OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition OdataTypeBasicRuleCondition = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" + // OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition ... + OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition OdataTypeBasicRuleCondition = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" + // OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition ... + OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition OdataTypeBasicRuleCondition = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" + // OdataTypeRuleCondition ... + OdataTypeRuleCondition OdataTypeBasicRuleCondition = "RuleCondition" +) + +// PossibleOdataTypeBasicRuleConditionValues returns an array of possible values for the OdataTypeBasicRuleCondition const type. +func PossibleOdataTypeBasicRuleConditionValues() []OdataTypeBasicRuleCondition { + return []OdataTypeBasicRuleCondition{OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition, OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition, OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition, OdataTypeRuleCondition} +} + +// OnboardingStatus enumerates the values for onboarding status. +type OnboardingStatus string + +const ( + // NotOnboarded ... + NotOnboarded OnboardingStatus = "notOnboarded" + // Onboarded ... + Onboarded OnboardingStatus = "onboarded" + // Unknown ... + Unknown OnboardingStatus = "unknown" +) + +// PossibleOnboardingStatusValues returns an array of possible values for the OnboardingStatus const type. +func PossibleOnboardingStatusValues() []OnboardingStatus { + return []OnboardingStatus{NotOnboarded, Onboarded, Unknown} +} + +// Operator enumerates the values for operator. +type Operator string + +const ( + // OperatorEquals ... + OperatorEquals Operator = "Equals" + // OperatorGreaterThan ... + OperatorGreaterThan Operator = "GreaterThan" + // OperatorGreaterThanOrEqual ... + OperatorGreaterThanOrEqual Operator = "GreaterThanOrEqual" + // OperatorLessThan ... + OperatorLessThan Operator = "LessThan" + // OperatorLessThanOrEqual ... + OperatorLessThanOrEqual Operator = "LessThanOrEqual" + // OperatorNotEquals ... + OperatorNotEquals Operator = "NotEquals" +) + +// PossibleOperatorValues returns an array of possible values for the Operator const type. +func PossibleOperatorValues() []Operator { + return []Operator{OperatorEquals, OperatorGreaterThan, OperatorGreaterThanOrEqual, OperatorLessThan, OperatorLessThanOrEqual, OperatorNotEquals} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeploying ... + ProvisioningStateDeploying ProvisioningState = "Deploying" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateCanceled, ProvisioningStateDeploying, ProvisioningStateFailed, ProvisioningStateSucceeded} +} + +// QueryType enumerates the values for query type. +type QueryType string + +const ( + // ResultCount ... + ResultCount QueryType = "ResultCount" +) + +// PossibleQueryTypeValues returns an array of possible values for the QueryType const type. +func PossibleQueryTypeValues() []QueryType { + return []QueryType{ResultCount} +} + +// ReceiverStatus enumerates the values for receiver status. +type ReceiverStatus string + +const ( + // ReceiverStatusDisabled ... + ReceiverStatusDisabled ReceiverStatus = "Disabled" + // ReceiverStatusEnabled ... + ReceiverStatusEnabled ReceiverStatus = "Enabled" + // ReceiverStatusNotSpecified ... + ReceiverStatusNotSpecified ReceiverStatus = "NotSpecified" +) + +// PossibleReceiverStatusValues returns an array of possible values for the ReceiverStatus const type. +func PossibleReceiverStatusValues() []ReceiverStatus { + return []ReceiverStatus{ReceiverStatusDisabled, ReceiverStatusEnabled, ReceiverStatusNotSpecified} +} + +// RecurrenceFrequency enumerates the values for recurrence frequency. +type RecurrenceFrequency string + +const ( + // RecurrenceFrequencyDay ... + RecurrenceFrequencyDay RecurrenceFrequency = "Day" + // RecurrenceFrequencyHour ... + RecurrenceFrequencyHour RecurrenceFrequency = "Hour" + // RecurrenceFrequencyMinute ... + RecurrenceFrequencyMinute RecurrenceFrequency = "Minute" + // RecurrenceFrequencyMonth ... + RecurrenceFrequencyMonth RecurrenceFrequency = "Month" + // RecurrenceFrequencyNone ... + RecurrenceFrequencyNone RecurrenceFrequency = "None" + // RecurrenceFrequencySecond ... + RecurrenceFrequencySecond RecurrenceFrequency = "Second" + // RecurrenceFrequencyWeek ... + RecurrenceFrequencyWeek RecurrenceFrequency = "Week" + // RecurrenceFrequencyYear ... + RecurrenceFrequencyYear RecurrenceFrequency = "Year" +) + +// PossibleRecurrenceFrequencyValues returns an array of possible values for the RecurrenceFrequency const type. +func PossibleRecurrenceFrequencyValues() []RecurrenceFrequency { + return []RecurrenceFrequency{RecurrenceFrequencyDay, RecurrenceFrequencyHour, RecurrenceFrequencyMinute, RecurrenceFrequencyMonth, RecurrenceFrequencyNone, RecurrenceFrequencySecond, RecurrenceFrequencyWeek, RecurrenceFrequencyYear} +} + +// ResultType enumerates the values for result type. +type ResultType string + +const ( + // Data ... + Data ResultType = "Data" + // Metadata ... + Metadata ResultType = "Metadata" +) + +// PossibleResultTypeValues returns an array of possible values for the ResultType const type. +func PossibleResultTypeValues() []ResultType { + return []ResultType{Data, Metadata} +} + +// ScaleDirection enumerates the values for scale direction. +type ScaleDirection string + +const ( + // ScaleDirectionDecrease ... + ScaleDirectionDecrease ScaleDirection = "Decrease" + // ScaleDirectionIncrease ... + ScaleDirectionIncrease ScaleDirection = "Increase" + // ScaleDirectionNone ... + ScaleDirectionNone ScaleDirection = "None" +) + +// PossibleScaleDirectionValues returns an array of possible values for the ScaleDirection const type. +func PossibleScaleDirectionValues() []ScaleDirection { + return []ScaleDirection{ScaleDirectionDecrease, ScaleDirectionIncrease, ScaleDirectionNone} +} + +// ScaleRuleMetricDimensionOperationType enumerates the values for scale rule metric dimension operation type. +type ScaleRuleMetricDimensionOperationType string + +const ( + // ScaleRuleMetricDimensionOperationTypeEquals ... + ScaleRuleMetricDimensionOperationTypeEquals ScaleRuleMetricDimensionOperationType = "Equals" + // ScaleRuleMetricDimensionOperationTypeNotEquals ... + ScaleRuleMetricDimensionOperationTypeNotEquals ScaleRuleMetricDimensionOperationType = "NotEquals" +) + +// PossibleScaleRuleMetricDimensionOperationTypeValues returns an array of possible values for the ScaleRuleMetricDimensionOperationType const type. +func PossibleScaleRuleMetricDimensionOperationTypeValues() []ScaleRuleMetricDimensionOperationType { + return []ScaleRuleMetricDimensionOperationType{ScaleRuleMetricDimensionOperationTypeEquals, ScaleRuleMetricDimensionOperationTypeNotEquals} +} + +// ScaleType enumerates the values for scale type. +type ScaleType string + +const ( + // ChangeCount ... + ChangeCount ScaleType = "ChangeCount" + // ExactCount ... + ExactCount ScaleType = "ExactCount" + // PercentChangeCount ... + PercentChangeCount ScaleType = "PercentChangeCount" +) + +// PossibleScaleTypeValues returns an array of possible values for the ScaleType const type. +func PossibleScaleTypeValues() []ScaleType { + return []ScaleType{ChangeCount, ExactCount, PercentChangeCount} +} + +// TimeAggregationOperator enumerates the values for time aggregation operator. +type TimeAggregationOperator string + +const ( + // TimeAggregationOperatorAverage ... + TimeAggregationOperatorAverage TimeAggregationOperator = "Average" + // TimeAggregationOperatorLast ... + TimeAggregationOperatorLast TimeAggregationOperator = "Last" + // TimeAggregationOperatorMaximum ... + TimeAggregationOperatorMaximum TimeAggregationOperator = "Maximum" + // TimeAggregationOperatorMinimum ... + TimeAggregationOperatorMinimum TimeAggregationOperator = "Minimum" + // TimeAggregationOperatorTotal ... + TimeAggregationOperatorTotal TimeAggregationOperator = "Total" +) + +// PossibleTimeAggregationOperatorValues returns an array of possible values for the TimeAggregationOperator const type. +func PossibleTimeAggregationOperatorValues() []TimeAggregationOperator { + return []TimeAggregationOperator{TimeAggregationOperatorAverage, TimeAggregationOperatorLast, TimeAggregationOperatorMaximum, TimeAggregationOperatorMinimum, TimeAggregationOperatorTotal} +} + +// TimeAggregationType enumerates the values for time aggregation type. +type TimeAggregationType string + +const ( + // TimeAggregationTypeAverage ... + TimeAggregationTypeAverage TimeAggregationType = "Average" + // TimeAggregationTypeCount ... + TimeAggregationTypeCount TimeAggregationType = "Count" + // TimeAggregationTypeLast ... + TimeAggregationTypeLast TimeAggregationType = "Last" + // TimeAggregationTypeMaximum ... + TimeAggregationTypeMaximum TimeAggregationType = "Maximum" + // TimeAggregationTypeMinimum ... + TimeAggregationTypeMinimum TimeAggregationType = "Minimum" + // TimeAggregationTypeTotal ... + TimeAggregationTypeTotal TimeAggregationType = "Total" +) + +// PossibleTimeAggregationTypeValues returns an array of possible values for the TimeAggregationType const type. +func PossibleTimeAggregationTypeValues() []TimeAggregationType { + return []TimeAggregationType{TimeAggregationTypeAverage, TimeAggregationTypeCount, TimeAggregationTypeLast, TimeAggregationTypeMaximum, TimeAggregationTypeMinimum, TimeAggregationTypeTotal} +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/eventcategories.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/eventcategories.go new file mode 100644 index 000000000000..86e59b424363 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/eventcategories.go @@ -0,0 +1,99 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// EventCategoriesClient is the monitor Management Client +type EventCategoriesClient struct { + BaseClient +} + +// NewEventCategoriesClient creates an instance of the EventCategoriesClient client. +func NewEventCategoriesClient(subscriptionID string) EventCategoriesClient { + return NewEventCategoriesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEventCategoriesClientWithBaseURI creates an instance of the EventCategoriesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewEventCategoriesClientWithBaseURI(baseURI string, subscriptionID string) EventCategoriesClient { + return EventCategoriesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get the list of available event categories supported in the Activity Logs Service.
The current list includes +// the following: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. +func (client EventCategoriesClient) List(ctx context.Context) (result EventCategoryCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventCategoriesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.EventCategoriesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.EventCategoriesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.EventCategoriesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client EventCategoriesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/microsoft.insights/eventcategories"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client EventCategoriesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client EventCategoriesClient) ListResponder(resp *http.Response) (result EventCategoryCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/insightsapi/interfaces.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/insightsapi/interfaces.go new file mode 100644 index 000000000000..88f2dd9222b8 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/insightsapi/interfaces.go @@ -0,0 +1,291 @@ +package insightsapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-04-01-preview/insights" + "github.com/Azure/go-autorest/autorest" +) + +// AutoscaleSettingsClientAPI contains the set of methods on the AutoscaleSettingsClient type. +type AutoscaleSettingsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters insights.AutoscaleSettingResource) (result insights.AutoscaleSettingResource, err error) + Delete(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result insights.AutoscaleSettingResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.AutoscaleSettingResourceCollectionPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result insights.AutoscaleSettingResourceCollectionIterator, err error) + ListBySubscription(ctx context.Context) (result insights.AutoscaleSettingResourceCollectionPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result insights.AutoscaleSettingResourceCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource insights.AutoscaleSettingResourcePatch) (result insights.AutoscaleSettingResource, err error) +} + +var _ AutoscaleSettingsClientAPI = (*insights.AutoscaleSettingsClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result insights.OperationListResult, err error) +} + +var _ OperationsClientAPI = (*insights.OperationsClient)(nil) + +// AlertRuleIncidentsClientAPI contains the set of methods on the AlertRuleIncidentsClient type. +type AlertRuleIncidentsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, ruleName string, incidentName string) (result insights.Incident, err error) + ListByAlertRule(ctx context.Context, resourceGroupName string, ruleName string) (result insights.IncidentListResult, err error) +} + +var _ AlertRuleIncidentsClientAPI = (*insights.AlertRuleIncidentsClient)(nil) + +// AlertRulesClientAPI contains the set of methods on the AlertRulesClient type. +type AlertRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters insights.AlertRuleResource) (result insights.AlertRuleResource, err error) + Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, ruleName string) (result insights.AlertRuleResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.AlertRuleResourceCollection, err error) + ListBySubscription(ctx context.Context) (result insights.AlertRuleResourceCollection, err error) + Update(ctx context.Context, resourceGroupName string, ruleName string, alertRulesResource insights.AlertRuleResourcePatch) (result insights.AlertRuleResource, err error) +} + +var _ AlertRulesClientAPI = (*insights.AlertRulesClient)(nil) + +// LogProfilesClientAPI contains the set of methods on the LogProfilesClient type. +type LogProfilesClientAPI interface { + CreateOrUpdate(ctx context.Context, logProfileName string, parameters insights.LogProfileResource) (result insights.LogProfileResource, err error) + Delete(ctx context.Context, logProfileName string) (result autorest.Response, err error) + Get(ctx context.Context, logProfileName string) (result insights.LogProfileResource, err error) + List(ctx context.Context) (result insights.LogProfileCollection, err error) + Update(ctx context.Context, logProfileName string, logProfilesResource insights.LogProfileResourcePatch) (result insights.LogProfileResource, err error) +} + +var _ LogProfilesClientAPI = (*insights.LogProfilesClient)(nil) + +// DiagnosticSettingsClientAPI contains the set of methods on the DiagnosticSettingsClient type. +type DiagnosticSettingsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceURI string, parameters insights.DiagnosticSettingsResource, name string) (result insights.DiagnosticSettingsResource, err error) + Delete(ctx context.Context, resourceURI string, name string) (result autorest.Response, err error) + Get(ctx context.Context, resourceURI string, name string) (result insights.DiagnosticSettingsResource, err error) + List(ctx context.Context, resourceURI string) (result insights.DiagnosticSettingsResourceCollection, err error) +} + +var _ DiagnosticSettingsClientAPI = (*insights.DiagnosticSettingsClient)(nil) + +// DiagnosticSettingsCategoryClientAPI contains the set of methods on the DiagnosticSettingsCategoryClient type. +type DiagnosticSettingsCategoryClientAPI interface { + Get(ctx context.Context, resourceURI string, name string) (result insights.DiagnosticSettingsCategoryResource, err error) + List(ctx context.Context, resourceURI string) (result insights.DiagnosticSettingsCategoryResourceCollection, err error) +} + +var _ DiagnosticSettingsCategoryClientAPI = (*insights.DiagnosticSettingsCategoryClient)(nil) + +// ActionGroupsClientAPI contains the set of methods on the ActionGroupsClient type. +type ActionGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup insights.ActionGroupResource) (result insights.ActionGroupResource, err error) + Delete(ctx context.Context, resourceGroupName string, actionGroupName string) (result autorest.Response, err error) + EnableReceiver(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest insights.EnableRequest) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, actionGroupName string) (result insights.ActionGroupResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.ActionGroupList, err error) + ListBySubscriptionID(ctx context.Context) (result insights.ActionGroupList, err error) + Update(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch insights.ActionGroupPatchBody) (result insights.ActionGroupResource, err error) +} + +var _ ActionGroupsClientAPI = (*insights.ActionGroupsClient)(nil) + +// ActivityLogsClientAPI contains the set of methods on the ActivityLogsClient type. +type ActivityLogsClientAPI interface { + List(ctx context.Context, filter string, selectParameter string) (result insights.EventDataCollectionPage, err error) + ListComplete(ctx context.Context, filter string, selectParameter string) (result insights.EventDataCollectionIterator, err error) +} + +var _ ActivityLogsClientAPI = (*insights.ActivityLogsClient)(nil) + +// EventCategoriesClientAPI contains the set of methods on the EventCategoriesClient type. +type EventCategoriesClientAPI interface { + List(ctx context.Context) (result insights.EventCategoryCollection, err error) +} + +var _ EventCategoriesClientAPI = (*insights.EventCategoriesClient)(nil) + +// TenantActivityLogsClientAPI contains the set of methods on the TenantActivityLogsClient type. +type TenantActivityLogsClientAPI interface { + List(ctx context.Context, filter string, selectParameter string) (result insights.EventDataCollectionPage, err error) + ListComplete(ctx context.Context, filter string, selectParameter string) (result insights.EventDataCollectionIterator, err error) +} + +var _ TenantActivityLogsClientAPI = (*insights.TenantActivityLogsClient)(nil) + +// MetricDefinitionsClientAPI contains the set of methods on the MetricDefinitionsClient type. +type MetricDefinitionsClientAPI interface { + List(ctx context.Context, resourceURI string, metricnamespace string) (result insights.MetricDefinitionCollection, err error) +} + +var _ MetricDefinitionsClientAPI = (*insights.MetricDefinitionsClient)(nil) + +// MetricsClientAPI contains the set of methods on the MetricsClient type. +type MetricsClientAPI interface { + List(ctx context.Context, resourceURI string, timespan string, interval *string, metricnames string, aggregation string, top *int32, orderby string, filter string, resultType insights.ResultType, metricnamespace string) (result insights.Response, err error) +} + +var _ MetricsClientAPI = (*insights.MetricsClient)(nil) + +// BaselinesClientAPI contains the set of methods on the BaselinesClient type. +type BaselinesClientAPI interface { + List(ctx context.Context, resourceURI string, metricnames string, metricnamespace string, timespan string, interval *string, aggregation string, sensitivities string, filter string, resultType insights.ResultType) (result insights.MetricBaselinesResponse, err error) +} + +var _ BaselinesClientAPI = (*insights.BaselinesClient)(nil) + +// MetricAlertsClientAPI contains the set of methods on the MetricAlertsClient type. +type MetricAlertsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters insights.MetricAlertResource) (result insights.MetricAlertResource, err error) + Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, ruleName string) (result insights.MetricAlertResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.MetricAlertResourceCollection, err error) + ListBySubscription(ctx context.Context) (result insights.MetricAlertResourceCollection, err error) + Update(ctx context.Context, resourceGroupName string, ruleName string, parameters insights.MetricAlertResourcePatch) (result insights.MetricAlertResource, err error) +} + +var _ MetricAlertsClientAPI = (*insights.MetricAlertsClient)(nil) + +// MetricAlertsStatusClientAPI contains the set of methods on the MetricAlertsStatusClient type. +type MetricAlertsStatusClientAPI interface { + List(ctx context.Context, resourceGroupName string, ruleName string) (result insights.MetricAlertStatusCollection, err error) + ListByName(ctx context.Context, resourceGroupName string, ruleName string, statusName string) (result insights.MetricAlertStatusCollection, err error) +} + +var _ MetricAlertsStatusClientAPI = (*insights.MetricAlertsStatusClient)(nil) + +// ScheduledQueryRulesClientAPI contains the set of methods on the ScheduledQueryRulesClient type. +type ScheduledQueryRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters insights.LogSearchRuleResource) (result insights.LogSearchRuleResource, err error) + Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, ruleName string) (result insights.LogSearchRuleResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result insights.LogSearchRuleResourceCollection, err error) + ListBySubscription(ctx context.Context, filter string) (result insights.LogSearchRuleResourceCollection, err error) + Update(ctx context.Context, resourceGroupName string, ruleName string, parameters insights.LogSearchRuleResourcePatch) (result insights.LogSearchRuleResource, err error) +} + +var _ ScheduledQueryRulesClientAPI = (*insights.ScheduledQueryRulesClient)(nil) + +// MetricNamespacesClientAPI contains the set of methods on the MetricNamespacesClient type. +type MetricNamespacesClientAPI interface { + List(ctx context.Context, resourceURI string, startTime string) (result insights.MetricNamespaceCollection, err error) +} + +var _ MetricNamespacesClientAPI = (*insights.MetricNamespacesClient)(nil) + +// VMInsightsClientAPI contains the set of methods on the VMInsightsClient type. +type VMInsightsClientAPI interface { + GetOnboardingStatus(ctx context.Context, resourceURI string) (result insights.VMInsightsOnboardingStatus, err error) +} + +var _ VMInsightsClientAPI = (*insights.VMInsightsClient)(nil) + +// PrivateLinkScopesClientAPI contains the set of methods on the PrivateLinkScopesClient type. +type PrivateLinkScopesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, azureMonitorPrivateLinkScopePayload insights.AzureMonitorPrivateLinkScope) (result insights.AzureMonitorPrivateLinkScope, err error) + Delete(ctx context.Context, resourceGroupName string, scopeName string) (result insights.PrivateLinkScopesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, scopeName string) (result insights.AzureMonitorPrivateLinkScope, err error) + List(ctx context.Context) (result insights.AzureMonitorPrivateLinkScopeListResultPage, err error) + ListComplete(ctx context.Context) (result insights.AzureMonitorPrivateLinkScopeListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.AzureMonitorPrivateLinkScopeListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result insights.AzureMonitorPrivateLinkScopeListResultIterator, err error) + UpdateTags(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags insights.TagsResource) (result insights.AzureMonitorPrivateLinkScope, err error) +} + +var _ PrivateLinkScopesClientAPI = (*insights.PrivateLinkScopesClient)(nil) + +// PrivateLinkScopeOperationStatusClientAPI contains the set of methods on the PrivateLinkScopeOperationStatusClient type. +type PrivateLinkScopeOperationStatusClientAPI interface { + Get(ctx context.Context, asyncOperationID string, resourceGroupName string) (result insights.OperationStatus, err error) +} + +var _ PrivateLinkScopeOperationStatusClientAPI = (*insights.PrivateLinkScopeOperationStatusClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, scopeName string, groupName string) (result insights.PrivateLinkResource, err error) + ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result insights.PrivateLinkResourceListResultPage, err error) + ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result insights.PrivateLinkResourceListResultIterator, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*insights.PrivateLinkResourcesClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, parameters insights.PrivateEndpointConnection) (result insights.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (result insights.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (result insights.PrivateEndpointConnection, err error) + ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result insights.PrivateEndpointConnectionListResultPage, err error) + ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result insights.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*insights.PrivateEndpointConnectionsClient)(nil) + +// PrivateLinkScopedResourcesClientAPI contains the set of methods on the PrivateLinkScopedResourcesClient type. +type PrivateLinkScopedResourcesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, name string, parameters insights.ScopedResource) (result insights.PrivateLinkScopedResourcesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, scopeName string, name string) (result insights.PrivateLinkScopedResourcesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, scopeName string, name string) (result insights.ScopedResource, err error) + ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result insights.ScopedResourceListResultPage, err error) + ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result insights.ScopedResourceListResultIterator, err error) +} + +var _ PrivateLinkScopedResourcesClientAPI = (*insights.PrivateLinkScopedResourcesClient)(nil) + +// ActivityLogAlertsClientAPI contains the set of methods on the ActivityLogAlertsClient type. +type ActivityLogAlertsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlert insights.ActivityLogAlertResource) (result insights.ActivityLogAlertResource, err error) + Delete(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result insights.ActivityLogAlertResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.ActivityLogAlertList, err error) + ListBySubscriptionID(ctx context.Context) (result insights.ActivityLogAlertList, err error) + Update(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertPatch insights.ActivityLogAlertPatchBody) (result insights.ActivityLogAlertResource, err error) +} + +var _ ActivityLogAlertsClientAPI = (*insights.ActivityLogAlertsClient)(nil) + +// DataCollectionEndpointsClientAPI contains the set of methods on the DataCollectionEndpointsClient type. +type DataCollectionEndpointsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *insights.DataCollectionEndpointResource) (result insights.DataCollectionEndpointResource, err error) + Delete(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (result insights.DataCollectionEndpointResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.DataCollectionEndpointResourceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result insights.DataCollectionEndpointResourceListResultIterator, err error) + ListBySubscription(ctx context.Context) (result insights.DataCollectionEndpointResourceListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result insights.DataCollectionEndpointResourceListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *insights.ResourceForUpdate) (result insights.DataCollectionEndpointResource, err error) +} + +var _ DataCollectionEndpointsClientAPI = (*insights.DataCollectionEndpointsClient)(nil) + +// DataCollectionRuleAssociationsClientAPI contains the set of methods on the DataCollectionRuleAssociationsClient type. +type DataCollectionRuleAssociationsClientAPI interface { + Create(ctx context.Context, resourceURI string, associationName string, body *insights.DataCollectionRuleAssociationProxyOnlyResource) (result insights.DataCollectionRuleAssociationProxyOnlyResource, err error) + Delete(ctx context.Context, resourceURI string, associationName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceURI string, associationName string) (result insights.DataCollectionRuleAssociationProxyOnlyResource, err error) + ListByResource(ctx context.Context, resourceURI string) (result insights.DataCollectionRuleAssociationProxyOnlyResourceListResultPage, err error) + ListByResourceComplete(ctx context.Context, resourceURI string) (result insights.DataCollectionRuleAssociationProxyOnlyResourceListResultIterator, err error) + ListByRule(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result insights.DataCollectionRuleAssociationProxyOnlyResourceListResultPage, err error) + ListByRuleComplete(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result insights.DataCollectionRuleAssociationProxyOnlyResourceListResultIterator, err error) +} + +var _ DataCollectionRuleAssociationsClientAPI = (*insights.DataCollectionRuleAssociationsClient)(nil) + +// DataCollectionRulesClientAPI contains the set of methods on the DataCollectionRulesClient type. +type DataCollectionRulesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *insights.DataCollectionRuleResource) (result insights.DataCollectionRuleResource, err error) + Delete(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result insights.DataCollectionRuleResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.DataCollectionRuleResourceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result insights.DataCollectionRuleResourceListResultIterator, err error) + ListBySubscription(ctx context.Context) (result insights.DataCollectionRuleResourceListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result insights.DataCollectionRuleResourceListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *insights.ResourceForUpdate) (result insights.DataCollectionRuleResource, err error) +} + +var _ DataCollectionRulesClientAPI = (*insights.DataCollectionRulesClient)(nil) diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/logprofiles.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/logprofiles.go new file mode 100644 index 000000000000..64fda18dde7c --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/logprofiles.go @@ -0,0 +1,444 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// LogProfilesClient is the monitor Management Client +type LogProfilesClient struct { + BaseClient +} + +// NewLogProfilesClient creates an instance of the LogProfilesClient client. +func NewLogProfilesClient(subscriptionID string) LogProfilesClient { + return NewLogProfilesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLogProfilesClientWithBaseURI creates an instance of the LogProfilesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewLogProfilesClientWithBaseURI(baseURI string, subscriptionID string) LogProfilesClient { + return LogProfilesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a log profile in Azure Monitoring REST API. +// Parameters: +// logProfileName - the name of the log profile. +// parameters - parameters supplied to the operation. +func (client LogProfilesClient) CreateOrUpdate(ctx context.Context, logProfileName string, parameters LogProfileResource) (result LogProfileResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.LogProfileProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.Locations", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogProfileProperties.Categories", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogProfileProperties.RetentionPolicy", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.RetentionPolicy.Enabled", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogProfileProperties.RetentionPolicy.Days", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.RetentionPolicy.Days", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}, + }}, + }}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.LogProfilesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, logProfileName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client LogProfilesClient) CreateOrUpdatePreparer(ctx context.Context, logProfileName string, parameters LogProfileResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client LogProfilesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) CreateOrUpdateResponder(resp *http.Response) (result LogProfileResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the log profile. +// Parameters: +// logProfileName - the name of the log profile. +func (client LogProfilesClient) Delete(ctx context.Context, logProfileName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.LogProfilesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, logProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LogProfilesClient) DeletePreparer(ctx context.Context, logProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LogProfilesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the log profile. +// Parameters: +// logProfileName - the name of the log profile. +func (client LogProfilesClient) Get(ctx context.Context, logProfileName string) (result LogProfileResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.LogProfilesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, logProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client LogProfilesClient) GetPreparer(ctx context.Context, logProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LogProfilesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) GetResponder(resp *http.Response) (result LogProfileResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list the log profiles. +func (client LogProfilesClient) List(ctx context.Context) (result LogProfileCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.LogProfilesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client LogProfilesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client LogProfilesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) ListResponder(resp *http.Response) (result LogProfileCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. +// Parameters: +// logProfileName - the name of the log profile. +// logProfilesResource - parameters supplied to the operation. +func (client LogProfilesClient) Update(ctx context.Context, logProfileName string, logProfilesResource LogProfileResourcePatch) (result LogProfileResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.LogProfilesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, logProfileName, logProfilesResource) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client LogProfilesClient) UpdatePreparer(ctx context.Context, logProfileName string, logProfilesResource LogProfileResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", pathParameters), + autorest.WithJSON(logProfilesResource), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client LogProfilesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) UpdateResponder(resp *http.Response) (result LogProfileResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalerts.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalerts.go new file mode 100644 index 000000000000..f9706664d9be --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalerts.go @@ -0,0 +1,545 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MetricAlertsClient is the monitor Management Client +type MetricAlertsClient struct { + BaseClient +} + +// NewMetricAlertsClient creates an instance of the MetricAlertsClient client. +func NewMetricAlertsClient(subscriptionID string) MetricAlertsClient { + return NewMetricAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMetricAlertsClientWithBaseURI creates an instance of the MetricAlertsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewMetricAlertsClientWithBaseURI(baseURI string, subscriptionID string) MetricAlertsClient { + return MetricAlertsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update an metric alert definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// parameters - the parameters of the rule to create or update. +func (client MetricAlertsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResource) (result MetricAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.MetricAlertProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.MetricAlertProperties.Severity", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.MetricAlertProperties.Enabled", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.MetricAlertProperties.Scopes", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.MetricAlertProperties.EvaluationFrequency", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.MetricAlertProperties.WindowSize", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client MetricAlertsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client MetricAlertsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) CreateOrUpdateResponder(resp *http.Response) (result MetricAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an alert rule definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client MetricAlertsClient) Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client MetricAlertsClient) DeletePreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client MetricAlertsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve an alert rule definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client MetricAlertsClient) Get(ctx context.Context, resourceGroupName string, ruleName string) (result MetricAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client MetricAlertsClient) GetPreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client MetricAlertsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) GetResponder(resp *http.Response) (result MetricAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup retrieve alert rule definitions in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client MetricAlertsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result MetricAlertResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client MetricAlertsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client MetricAlertsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) ListByResourceGroupResponder(resp *http.Response) (result MetricAlertResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription retrieve alert rule definitions in a subscription. +func (client MetricAlertsClient) ListBySubscription(ctx context.Context) (result MetricAlertResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client MetricAlertsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client MetricAlertsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) ListBySubscriptionResponder(resp *http.Response) (result MetricAlertResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update an metric alert definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// parameters - the parameters of the rule to update. +func (client MetricAlertsClient) Update(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResourcePatch) (result MetricAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client MetricAlertsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client MetricAlertsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) UpdateResponder(resp *http.Response) (result MetricAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalertsstatus.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalertsstatus.go new file mode 100644 index 000000000000..4709142160be --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalertsstatus.go @@ -0,0 +1,205 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MetricAlertsStatusClient is the monitor Management Client +type MetricAlertsStatusClient struct { + BaseClient +} + +// NewMetricAlertsStatusClient creates an instance of the MetricAlertsStatusClient client. +func NewMetricAlertsStatusClient(subscriptionID string) MetricAlertsStatusClient { + return NewMetricAlertsStatusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMetricAlertsStatusClientWithBaseURI creates an instance of the MetricAlertsStatusClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewMetricAlertsStatusClientWithBaseURI(baseURI string, subscriptionID string) MetricAlertsStatusClient { + return MetricAlertsStatusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List retrieve an alert rule status. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client MetricAlertsStatusClient) List(ctx context.Context, resourceGroupName string, ruleName string) (result MetricAlertStatusCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsStatusClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsStatusClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client MetricAlertsStatusClient) ListPreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client MetricAlertsStatusClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client MetricAlertsStatusClient) ListResponder(resp *http.Response) (result MetricAlertStatusCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByName retrieve an alert rule status. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// statusName - the name of the status. +func (client MetricAlertsStatusClient) ListByName(ctx context.Context, resourceGroupName string, ruleName string, statusName string) (result MetricAlertStatusCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsStatusClient.ListByName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsStatusClient", "ListByName", err.Error()) + } + + req, err := client.ListByNamePreparer(ctx, resourceGroupName, ruleName, statusName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "ListByName", nil, "Failure preparing request") + return + } + + resp, err := client.ListByNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "ListByName", resp, "Failure sending request") + return + } + + result, err = client.ListByNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "ListByName", resp, "Failure responding to request") + return + } + + return +} + +// ListByNamePreparer prepares the ListByName request. +func (client MetricAlertsStatusClient) ListByNamePreparer(ctx context.Context, resourceGroupName string, ruleName string, statusName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "statusName": autorest.Encode("path", statusName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByNameSender sends the ListByName request. The method will close the +// http.Response Body if it receives an error. +func (client MetricAlertsStatusClient) ListByNameSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByNameResponder handles the response to the ListByName request. The method always +// closes the http.Response Body. +func (client MetricAlertsStatusClient) ListByNameResponder(resp *http.Response) (result MetricAlertStatusCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricdefinitions.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricdefinitions.go new file mode 100644 index 000000000000..e53a121e4bf7 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricdefinitions.go @@ -0,0 +1,116 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MetricDefinitionsClient is the monitor Management Client +type MetricDefinitionsClient struct { + BaseClient +} + +// NewMetricDefinitionsClient creates an instance of the MetricDefinitionsClient client. +func NewMetricDefinitionsClient(subscriptionID string) MetricDefinitionsClient { + return NewMetricDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMetricDefinitionsClientWithBaseURI creates an instance of the MetricDefinitionsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewMetricDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) MetricDefinitionsClient { + return MetricDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the metric definitions for the resource. +// Parameters: +// resourceURI - the identifier of the resource. +// metricnamespace - metric namespace to query metric definitions for. +func (client MetricDefinitionsClient) List(ctx context.Context, resourceURI string, metricnamespace string) (result MetricDefinitionCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricDefinitionsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricDefinitionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI, metricnamespace) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricDefinitionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricDefinitionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricDefinitionsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client MetricDefinitionsClient) ListPreparer(ctx context.Context, resourceURI string, metricnamespace string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2018-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(metricnamespace) > 0 { + queryParameters["metricnamespace"] = autorest.Encode("query", metricnamespace) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/metricDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client MetricDefinitionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client MetricDefinitionsClient) ListResponder(resp *http.Response) (result MetricDefinitionCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricnamespaces.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricnamespaces.go new file mode 100644 index 000000000000..a1a70c21f9d6 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricnamespaces.go @@ -0,0 +1,116 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MetricNamespacesClient is the monitor Management Client +type MetricNamespacesClient struct { + BaseClient +} + +// NewMetricNamespacesClient creates an instance of the MetricNamespacesClient client. +func NewMetricNamespacesClient(subscriptionID string) MetricNamespacesClient { + return NewMetricNamespacesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMetricNamespacesClientWithBaseURI creates an instance of the MetricNamespacesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewMetricNamespacesClientWithBaseURI(baseURI string, subscriptionID string) MetricNamespacesClient { + return MetricNamespacesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the metric namespaces for the resource. +// Parameters: +// resourceURI - the identifier of the resource. +// startTime - the ISO 8601 conform Date start time from which to query for metric namespaces. +func (client MetricNamespacesClient) List(ctx context.Context, resourceURI string, startTime string) (result MetricNamespaceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricNamespacesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricNamespacesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI, startTime) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricNamespacesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricNamespacesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricNamespacesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client MetricNamespacesClient) ListPreparer(ctx context.Context, resourceURI string, startTime string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2017-12-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(startTime) > 0 { + queryParameters["startTime"] = autorest.Encode("query", startTime) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/metricNamespaces", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client MetricNamespacesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client MetricNamespacesClient) ListResponder(resp *http.Response) (result MetricNamespaceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/metrics.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metrics.go new file mode 100644 index 000000000000..b37fc8ad812c --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metrics.go @@ -0,0 +1,163 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MetricsClient is the monitor Management Client +type MetricsClient struct { + BaseClient +} + +// NewMetricsClient creates an instance of the MetricsClient client. +func NewMetricsClient(subscriptionID string) MetricsClient { + return NewMetricsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMetricsClientWithBaseURI creates an instance of the MetricsClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewMetricsClientWithBaseURI(baseURI string, subscriptionID string) MetricsClient { + return MetricsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List **Lists the metric values for a resource**. +// Parameters: +// resourceURI - the identifier of the resource. +// timespan - the timespan of the query. It is a string with the following format +// 'startDateTime_ISO/endDateTime_ISO'. +// interval - the interval (i.e. timegrain) of the query. +// metricnames - the names of the metrics (comma separated) to retrieve. Special case: If a metricname itself +// has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'** +// aggregation - the list of aggregation types (comma separated) to retrieve. +// top - the maximum number of records to retrieve. +// Valid only if $filter is specified. +// Defaults to 10. +// orderby - the aggregation to use for sorting results and the direction of the sort. +// Only one order can be specified. +// Examples: sum asc. +// filter - the **$filter** is used to reduce the set of metric data returned. Example: Metric contains +// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq 'a1' and B +// eq 'b1' or B eq 'b2' and C eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' or B = +// 'b2'** This is invalid because the logical or operator cannot separate two different metadata names. - +// Return all time series where A = a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - +// Return all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C eq '*'**. Special case: When +// dimension name or dimension value uses round brackets. Eg: When dimension name is **dim (test) 1** Instead +// of using $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' "** When dimension name +// is **dim (test) 3** and dimension value is **dim3 (test) val** Instead of using $filter= "dim (test) 3 eq +// 'dim3 (test) val' " use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "** +// resultType - reduces the set of data collected. The syntax allowed depends on the operation. See the +// operation's description for details. +// metricnamespace - metric namespace to query metric definitions for. +func (client MetricsClient) List(ctx context.Context, resourceURI string, timespan string, interval *string, metricnames string, aggregation string, top *int32, orderby string, filter string, resultType ResultType, metricnamespace string) (result Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI, timespan, interval, metricnames, aggregation, top, orderby, filter, resultType, metricnamespace) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client MetricsClient) ListPreparer(ctx context.Context, resourceURI string, timespan string, interval *string, metricnames string, aggregation string, top *int32, orderby string, filter string, resultType ResultType, metricnamespace string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2018-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(timespan) > 0 { + queryParameters["timespan"] = autorest.Encode("query", timespan) + } + if interval != nil { + queryParameters["interval"] = autorest.Encode("query", *interval) + } + if len(metricnames) > 0 { + queryParameters["metricnames"] = autorest.Encode("query", metricnames) + } + if len(aggregation) > 0 { + queryParameters["aggregation"] = autorest.Encode("query", aggregation) + } + if top != nil { + queryParameters["top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["orderby"] = autorest.Encode("query", orderby) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(string(resultType)) > 0 { + queryParameters["resultType"] = autorest.Encode("query", resultType) + } + if len(metricnamespace) > 0 { + queryParameters["metricnamespace"] = autorest.Encode("query", metricnamespace) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client MetricsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client MetricsClient) ListResponder(resp *http.Response) (result Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/models.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/models.go new file mode 100644 index 000000000000..0d6190ab8f77 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/models.go @@ -0,0 +1,8740 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-04-01-preview/insights" + +// BasicAction action descriptor. +type BasicAction interface { + AsAlertingAction() (*AlertingAction, bool) + AsLogToMetricAction() (*LogToMetricAction, bool) + AsAction() (*Action, bool) +} + +// Action action descriptor. +type Action struct { + // OdataType - Possible values include: 'OdataTypeAction', 'OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction', 'OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction' + OdataType OdataTypeBasicAction `json:"odata.type,omitempty"` +} + +func unmarshalBasicAction(body []byte) (BasicAction, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction): + var aa AlertingAction + err := json.Unmarshal(body, &aa) + return aa, err + case string(OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction): + var ltma LogToMetricAction + err := json.Unmarshal(body, <ma) + return ltma, err + default: + var a Action + err := json.Unmarshal(body, &a) + return a, err + } +} +func unmarshalBasicActionArray(body []byte) ([]BasicAction, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + aArray := make([]BasicAction, len(rawMessages)) + + for index, rawMessage := range rawMessages { + a, err := unmarshalBasicAction(*rawMessage) + if err != nil { + return nil, err + } + aArray[index] = a + } + return aArray, nil +} + +// MarshalJSON is the custom marshaler for Action. +func (a Action) MarshalJSON() ([]byte, error) { + a.OdataType = OdataTypeAction + objectMap := make(map[string]interface{}) + if a.OdataType != "" { + objectMap["odata.type"] = a.OdataType + } + return json.Marshal(objectMap) +} + +// AsAlertingAction is the BasicAction implementation for Action. +func (a Action) AsAlertingAction() (*AlertingAction, bool) { + return nil, false +} + +// AsLogToMetricAction is the BasicAction implementation for Action. +func (a Action) AsLogToMetricAction() (*LogToMetricAction, bool) { + return nil, false +} + +// AsAction is the BasicAction implementation for Action. +func (a Action) AsAction() (*Action, bool) { + return &a, true +} + +// AsBasicAction is the BasicAction implementation for Action. +func (a Action) AsBasicAction() (BasicAction, bool) { + return &a, true +} + +// ActionGroup an Azure action group. +type ActionGroup struct { + // GroupShortName - The short name of the action group. This will be used in SMS messages. + GroupShortName *string `json:"groupShortName,omitempty"` + // Enabled - Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. + Enabled *bool `json:"enabled,omitempty"` + // EmailReceivers - The list of email receivers that are part of this action group. + EmailReceivers *[]EmailReceiver `json:"emailReceivers,omitempty"` + // SmsReceivers - The list of SMS receivers that are part of this action group. + SmsReceivers *[]SmsReceiver `json:"smsReceivers,omitempty"` + // WebhookReceivers - The list of webhook receivers that are part of this action group. + WebhookReceivers *[]WebhookReceiver `json:"webhookReceivers,omitempty"` + // ItsmReceivers - The list of ITSM receivers that are part of this action group. + ItsmReceivers *[]ItsmReceiver `json:"itsmReceivers,omitempty"` + // AzureAppPushReceivers - The list of AzureAppPush receivers that are part of this action group. + AzureAppPushReceivers *[]AzureAppPushReceiver `json:"azureAppPushReceivers,omitempty"` + // AutomationRunbookReceivers - The list of AutomationRunbook receivers that are part of this action group. + AutomationRunbookReceivers *[]AutomationRunbookReceiver `json:"automationRunbookReceivers,omitempty"` + // VoiceReceivers - The list of voice receivers that are part of this action group. + VoiceReceivers *[]VoiceReceiver `json:"voiceReceivers,omitempty"` + // LogicAppReceivers - The list of logic app receivers that are part of this action group. + LogicAppReceivers *[]LogicAppReceiver `json:"logicAppReceivers,omitempty"` + // AzureFunctionReceivers - The list of azure function receivers that are part of this action group. + AzureFunctionReceivers *[]AzureFunctionReceiver `json:"azureFunctionReceivers,omitempty"` + // ArmRoleReceivers - The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. + ArmRoleReceivers *[]ArmRoleReceiver `json:"armRoleReceivers,omitempty"` +} + +// ActionGroupList a list of action groups. +type ActionGroupList struct { + autorest.Response `json:"-"` + // Value - The list of action groups. + Value *[]ActionGroupResource `json:"value,omitempty"` + // NextLink - Provides the link to retrieve the next set of elements. + NextLink *string `json:"nextLink,omitempty"` +} + +// ActionGroupPatch an Azure action group for patch operations. +type ActionGroupPatch struct { + // Enabled - Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. + Enabled *bool `json:"enabled,omitempty"` +} + +// ActionGroupPatchBody an action group object for the body of patch operations. +type ActionGroupPatchBody struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // ActionGroupPatch - The action group settings for an update operation. + *ActionGroupPatch `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ActionGroupPatchBody. +func (agpb ActionGroupPatchBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if agpb.Tags != nil { + objectMap["tags"] = agpb.Tags + } + if agpb.ActionGroupPatch != nil { + objectMap["properties"] = agpb.ActionGroupPatch + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ActionGroupPatchBody struct. +func (agpb *ActionGroupPatchBody) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + agpb.Tags = tags + } + case "properties": + if v != nil { + var actionGroupPatch ActionGroupPatch + err = json.Unmarshal(*v, &actionGroupPatch) + if err != nil { + return err + } + agpb.ActionGroupPatch = &actionGroupPatch + } + } + } + + return nil +} + +// ActionGroupResource an action group resource. +type ActionGroupResource struct { + autorest.Response `json:"-"` + // ActionGroup - The action groups properties of the resource. + *ActionGroup `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Kind - READ-ONLY; Azure resource kind + Kind *string `json:"kind,omitempty"` + // Identity - READ-ONLY; Azure resource identity + Identity *string `json:"identity,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ActionGroupResource. +func (agr ActionGroupResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if agr.ActionGroup != nil { + objectMap["properties"] = agr.ActionGroup + } + if agr.Location != nil { + objectMap["location"] = agr.Location + } + if agr.Tags != nil { + objectMap["tags"] = agr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ActionGroupResource struct. +func (agr *ActionGroupResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var actionGroup ActionGroup + err = json.Unmarshal(*v, &actionGroup) + if err != nil { + return err + } + agr.ActionGroup = &actionGroup + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + agr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + agr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + agr.Type = &typeVar + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + agr.Kind = &kind + } + case "identity": + if v != nil { + var identity string + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + agr.Identity = &identity + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + agr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + agr.Tags = tags + } + } + } + + return nil +} + +// ActivityLogAlert an Azure activity log alert. +type ActivityLogAlert struct { + // Scopes - A list of resourceIds that will be used as prefixes. The alert will only apply to activityLogs with resourceIds that fall under one of these prefixes. This list must include at least one item. + Scopes *[]string `json:"scopes,omitempty"` + // Enabled - Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. + Enabled *bool `json:"enabled,omitempty"` + // Condition - The condition that will cause this alert to activate. + Condition *ActivityLogAlertAllOfCondition `json:"condition,omitempty"` + // Actions - The actions that will activate when the condition is met. + Actions *ActivityLogAlertActionList `json:"actions,omitempty"` + // Description - A description of this activity log alert. + Description *string `json:"description,omitempty"` +} + +// ActivityLogAlertActionGroup a pointer to an Azure Action Group. +type ActivityLogAlertActionGroup struct { + // ActionGroupID - The resourceId of the action group. This cannot be null or empty. + ActionGroupID *string `json:"actionGroupId,omitempty"` + // WebhookProperties - the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. + WebhookProperties map[string]*string `json:"webhookProperties"` +} + +// MarshalJSON is the custom marshaler for ActivityLogAlertActionGroup. +func (alaag ActivityLogAlertActionGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if alaag.ActionGroupID != nil { + objectMap["actionGroupId"] = alaag.ActionGroupID + } + if alaag.WebhookProperties != nil { + objectMap["webhookProperties"] = alaag.WebhookProperties + } + return json.Marshal(objectMap) +} + +// ActivityLogAlertActionList a list of activity log alert actions. +type ActivityLogAlertActionList struct { + // ActionGroups - The list of activity log alerts. + ActionGroups *[]ActivityLogAlertActionGroup `json:"actionGroups,omitempty"` +} + +// ActivityLogAlertAllOfCondition an Activity Log alert condition that is met when all its member +// conditions are met. +type ActivityLogAlertAllOfCondition struct { + // AllOf - The list of activity log alert conditions. + AllOf *[]ActivityLogAlertLeafCondition `json:"allOf,omitempty"` +} + +// ActivityLogAlertLeafCondition an Activity Log alert condition that is met by comparing an activity log +// field and value. +type ActivityLogAlertLeafCondition struct { + // Field - The name of the field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties.'. + Field *string `json:"field,omitempty"` + // Equals - The field value will be compared to this value (case-insensitive) to determine if the condition is met. + Equals *string `json:"equals,omitempty"` +} + +// ActivityLogAlertList a list of activity log alerts. +type ActivityLogAlertList struct { + autorest.Response `json:"-"` + // Value - The list of activity log alerts. + Value *[]ActivityLogAlertResource `json:"value,omitempty"` + // NextLink - Provides the link to retrieve the next set of elements. + NextLink *string `json:"nextLink,omitempty"` +} + +// ActivityLogAlertPatch an Azure activity log alert for patch operations. +type ActivityLogAlertPatch struct { + // Enabled - Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. + Enabled *bool `json:"enabled,omitempty"` +} + +// ActivityLogAlertPatchBody an activity log alert object for the body of patch operations. +type ActivityLogAlertPatchBody struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // ActivityLogAlertPatch - The activity log alert settings for an update operation. + *ActivityLogAlertPatch `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ActivityLogAlertPatchBody. +func (alapb ActivityLogAlertPatchBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if alapb.Tags != nil { + objectMap["tags"] = alapb.Tags + } + if alapb.ActivityLogAlertPatch != nil { + objectMap["properties"] = alapb.ActivityLogAlertPatch + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ActivityLogAlertPatchBody struct. +func (alapb *ActivityLogAlertPatchBody) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + alapb.Tags = tags + } + case "properties": + if v != nil { + var activityLogAlertPatch ActivityLogAlertPatch + err = json.Unmarshal(*v, &activityLogAlertPatch) + if err != nil { + return err + } + alapb.ActivityLogAlertPatch = &activityLogAlertPatch + } + } + } + + return nil +} + +// ActivityLogAlertResource an activity log alert resource. +type ActivityLogAlertResource struct { + autorest.Response `json:"-"` + // ActivityLogAlert - The activity log alert properties of the resource. + *ActivityLogAlert `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for ActivityLogAlertResource. +func (alar ActivityLogAlertResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if alar.ActivityLogAlert != nil { + objectMap["properties"] = alar.ActivityLogAlert + } + if alar.Location != nil { + objectMap["location"] = alar.Location + } + if alar.Tags != nil { + objectMap["tags"] = alar.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ActivityLogAlertResource struct. +func (alar *ActivityLogAlertResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var activityLogAlert ActivityLogAlert + err = json.Unmarshal(*v, &activityLogAlert) + if err != nil { + return err + } + alar.ActivityLogAlert = &activityLogAlert + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + alar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + alar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + alar.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + alar.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + alar.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + alar.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + alar.Etag = &etag + } + } + } + + return nil +} + +// AlertingAction specify action need to be taken when rule type is Alert +type AlertingAction struct { + // Severity - Severity of the alert. Possible values include: 'Zero', 'One', 'Two', 'Three', 'Four' + Severity AlertSeverity `json:"severity,omitempty"` + // AznsAction - Azure action group reference. + AznsAction *AzNsActionGroup `json:"aznsAction,omitempty"` + // ThrottlingInMin - time (in minutes) for which Alerts should be throttled or suppressed. + ThrottlingInMin *int32 `json:"throttlingInMin,omitempty"` + // Trigger - The trigger condition that results in the alert rule being. + Trigger *TriggerCondition `json:"trigger,omitempty"` + // OdataType - Possible values include: 'OdataTypeAction', 'OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction', 'OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction' + OdataType OdataTypeBasicAction `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertingAction. +func (aa AlertingAction) MarshalJSON() ([]byte, error) { + aa.OdataType = OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction + objectMap := make(map[string]interface{}) + if aa.Severity != "" { + objectMap["severity"] = aa.Severity + } + if aa.AznsAction != nil { + objectMap["aznsAction"] = aa.AznsAction + } + if aa.ThrottlingInMin != nil { + objectMap["throttlingInMin"] = aa.ThrottlingInMin + } + if aa.Trigger != nil { + objectMap["trigger"] = aa.Trigger + } + if aa.OdataType != "" { + objectMap["odata.type"] = aa.OdataType + } + return json.Marshal(objectMap) +} + +// AsAlertingAction is the BasicAction implementation for AlertingAction. +func (aa AlertingAction) AsAlertingAction() (*AlertingAction, bool) { + return &aa, true +} + +// AsLogToMetricAction is the BasicAction implementation for AlertingAction. +func (aa AlertingAction) AsLogToMetricAction() (*LogToMetricAction, bool) { + return nil, false +} + +// AsAction is the BasicAction implementation for AlertingAction. +func (aa AlertingAction) AsAction() (*Action, bool) { + return nil, false +} + +// AsBasicAction is the BasicAction implementation for AlertingAction. +func (aa AlertingAction) AsBasicAction() (BasicAction, bool) { + return &aa, true +} + +// AlertRule an alert rule. +type AlertRule struct { + // Name - the name of the alert rule. + Name *string `json:"name,omitempty"` + // Description - the description of the alert rule that will be included in the alert email. + Description *string `json:"description,omitempty"` + // ProvisioningState - the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty"` + // IsEnabled - the flag that indicates whether the alert rule is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` + // Condition - the condition that results in the alert rule being activated. + Condition BasicRuleCondition `json:"condition,omitempty"` + // Action - action that is performed when the alert rule becomes active, and when an alert condition is resolved. + Action BasicRuleAction `json:"action,omitempty"` + // Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + Actions *[]BasicRuleAction `json:"actions,omitempty"` + // LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format. + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertRule. +func (ar AlertRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ar.Name != nil { + objectMap["name"] = ar.Name + } + if ar.Description != nil { + objectMap["description"] = ar.Description + } + if ar.ProvisioningState != nil { + objectMap["provisioningState"] = ar.ProvisioningState + } + if ar.IsEnabled != nil { + objectMap["isEnabled"] = ar.IsEnabled + } + objectMap["condition"] = ar.Condition + objectMap["action"] = ar.Action + if ar.Actions != nil { + objectMap["actions"] = ar.Actions + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AlertRule struct. +func (ar *AlertRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ar.Name = &name + } + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + ar.Description = &description + } + case "provisioningState": + if v != nil { + var provisioningState string + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + ar.ProvisioningState = &provisioningState + } + case "isEnabled": + if v != nil { + var isEnabled bool + err = json.Unmarshal(*v, &isEnabled) + if err != nil { + return err + } + ar.IsEnabled = &isEnabled + } + case "condition": + if v != nil { + condition, err := unmarshalBasicRuleCondition(*v) + if err != nil { + return err + } + ar.Condition = condition + } + case "action": + if v != nil { + action, err := unmarshalBasicRuleAction(*v) + if err != nil { + return err + } + ar.Action = action + } + case "actions": + if v != nil { + actions, err := unmarshalBasicRuleActionArray(*v) + if err != nil { + return err + } + ar.Actions = &actions + } + case "lastUpdatedTime": + if v != nil { + var lastUpdatedTime date.Time + err = json.Unmarshal(*v, &lastUpdatedTime) + if err != nil { + return err + } + ar.LastUpdatedTime = &lastUpdatedTime + } + } + } + + return nil +} + +// AlertRuleResource the alert rule resource. +type AlertRuleResource struct { + autorest.Response `json:"-"` + // AlertRule - The alert rule properties of the resource. + *AlertRule `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertRuleResource. +func (arr AlertRuleResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arr.AlertRule != nil { + objectMap["properties"] = arr.AlertRule + } + if arr.Location != nil { + objectMap["location"] = arr.Location + } + if arr.Tags != nil { + objectMap["tags"] = arr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AlertRuleResource struct. +func (arr *AlertRuleResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var alertRule AlertRule + err = json.Unmarshal(*v, &alertRule) + if err != nil { + return err + } + arr.AlertRule = &alertRule + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + arr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + arr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + arr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + arr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + arr.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + arr.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + arr.Etag = &etag + } + } + } + + return nil +} + +// AlertRuleResourceCollection represents a collection of alert rule resources. +type AlertRuleResourceCollection struct { + autorest.Response `json:"-"` + // Value - the values for the alert rule resources. + Value *[]AlertRuleResource `json:"value,omitempty"` +} + +// AlertRuleResourcePatch the alert rule object for patch operations. +type AlertRuleResourcePatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // AlertRule - The properties of an alert rule. + *AlertRule `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertRuleResourcePatch. +func (arrp AlertRuleResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arrp.Tags != nil { + objectMap["tags"] = arrp.Tags + } + if arrp.AlertRule != nil { + objectMap["properties"] = arrp.AlertRule + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AlertRuleResourcePatch struct. +func (arrp *AlertRuleResourcePatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + arrp.Tags = tags + } + case "properties": + if v != nil { + var alertRule AlertRule + err = json.Unmarshal(*v, &alertRule) + if err != nil { + return err + } + arrp.AlertRule = &alertRule + } + } + } + + return nil +} + +// ArmRoleReceiver an arm role receiver. +type ArmRoleReceiver struct { + // Name - The name of the arm role receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // RoleID - The arm role id. + RoleID *string `json:"roleId,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// AutomationRunbookReceiver the Azure Automation Runbook notification receiver. +type AutomationRunbookReceiver struct { + // AutomationAccountID - The Azure automation account Id which holds this runbook and authenticate to Azure resource. + AutomationAccountID *string `json:"automationAccountId,omitempty"` + // RunbookName - The name for this runbook. + RunbookName *string `json:"runbookName,omitempty"` + // WebhookResourceID - The resource id for webhook linked to this runbook. + WebhookResourceID *string `json:"webhookResourceId,omitempty"` + // IsGlobalRunbook - Indicates whether this instance is global runbook. + IsGlobalRunbook *bool `json:"isGlobalRunbook,omitempty"` + // Name - Indicates name of the webhook. + Name *string `json:"name,omitempty"` + // ServiceURI - The URI where webhooks should be sent. + ServiceURI *string `json:"serviceUri,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// AutoscaleNotification autoscale notification. +type AutoscaleNotification struct { + // Operation - the operation associated with the notification and its value must be "scale" + Operation *string `json:"operation,omitempty"` + // Email - the email notification. + Email *EmailNotification `json:"email,omitempty"` + // Webhooks - the collection of webhook notifications. + Webhooks *[]WebhookNotification `json:"webhooks,omitempty"` +} + +// AutoscaleProfile autoscale profile. +type AutoscaleProfile struct { + // Name - the name of the profile. + Name *string `json:"name,omitempty"` + // Capacity - the number of instances that can be used during this profile. + Capacity *ScaleCapacity `json:"capacity,omitempty"` + // Rules - the collection of rules that provide the triggers and parameters for the scaling action. A maximum of 10 rules can be specified. + Rules *[]ScaleRule `json:"rules,omitempty"` + // FixedDate - the specific date-time for the profile. This element is not used if the Recurrence element is used. + FixedDate *TimeWindow `json:"fixedDate,omitempty"` + // Recurrence - the repeating times at which this profile begins. This element is not used if the FixedDate element is used. + Recurrence *Recurrence `json:"recurrence,omitempty"` +} + +// AutoscaleSetting a setting that contains all of the configuration for the automatic scaling of a +// resource. +type AutoscaleSetting struct { + // Profiles - the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. + Profiles *[]AutoscaleProfile `json:"profiles,omitempty"` + // Notifications - the collection of notifications. + Notifications *[]AutoscaleNotification `json:"notifications,omitempty"` + // Enabled - the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. + Enabled *bool `json:"enabled,omitempty"` + // Name - the name of the autoscale setting. + Name *string `json:"name,omitempty"` + // TargetResourceURI - the resource identifier of the resource that the autoscale setting should be added to. + TargetResourceURI *string `json:"targetResourceUri,omitempty"` +} + +// AutoscaleSettingResource the autoscale setting resource. +type AutoscaleSettingResource struct { + autorest.Response `json:"-"` + // AutoscaleSetting - The autoscale setting of the resource. + *AutoscaleSetting `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutoscaleSettingResource. +func (asr AutoscaleSettingResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asr.AutoscaleSetting != nil { + objectMap["properties"] = asr.AutoscaleSetting + } + if asr.Location != nil { + objectMap["location"] = asr.Location + } + if asr.Tags != nil { + objectMap["tags"] = asr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AutoscaleSettingResource struct. +func (asr *AutoscaleSettingResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var autoscaleSetting AutoscaleSetting + err = json.Unmarshal(*v, &autoscaleSetting) + if err != nil { + return err + } + asr.AutoscaleSetting = &autoscaleSetting + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + asr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + asr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + asr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + asr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + asr.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + asr.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + asr.Etag = &etag + } + } + } + + return nil +} + +// AutoscaleSettingResourceCollection represents a collection of autoscale setting resources. +type AutoscaleSettingResourceCollection struct { + autorest.Response `json:"-"` + // Value - the values for the autoscale setting resources. + Value *[]AutoscaleSettingResource `json:"value,omitempty"` + // NextLink - URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// AutoscaleSettingResourceCollectionIterator provides access to a complete listing of +// AutoscaleSettingResource values. +type AutoscaleSettingResourceCollectionIterator struct { + i int + page AutoscaleSettingResourceCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AutoscaleSettingResourceCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingResourceCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AutoscaleSettingResourceCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AutoscaleSettingResourceCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AutoscaleSettingResourceCollectionIterator) Response() AutoscaleSettingResourceCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AutoscaleSettingResourceCollectionIterator) Value() AutoscaleSettingResource { + if !iter.page.NotDone() { + return AutoscaleSettingResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AutoscaleSettingResourceCollectionIterator type. +func NewAutoscaleSettingResourceCollectionIterator(page AutoscaleSettingResourceCollectionPage) AutoscaleSettingResourceCollectionIterator { + return AutoscaleSettingResourceCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (asrc AutoscaleSettingResourceCollection) IsEmpty() bool { + return asrc.Value == nil || len(*asrc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (asrc AutoscaleSettingResourceCollection) hasNextLink() bool { + return asrc.NextLink != nil && len(*asrc.NextLink) != 0 +} + +// autoscaleSettingResourceCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (asrc AutoscaleSettingResourceCollection) autoscaleSettingResourceCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !asrc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(asrc.NextLink))) +} + +// AutoscaleSettingResourceCollectionPage contains a page of AutoscaleSettingResource values. +type AutoscaleSettingResourceCollectionPage struct { + fn func(context.Context, AutoscaleSettingResourceCollection) (AutoscaleSettingResourceCollection, error) + asrc AutoscaleSettingResourceCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AutoscaleSettingResourceCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingResourceCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.asrc) + if err != nil { + return err + } + page.asrc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AutoscaleSettingResourceCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AutoscaleSettingResourceCollectionPage) NotDone() bool { + return !page.asrc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AutoscaleSettingResourceCollectionPage) Response() AutoscaleSettingResourceCollection { + return page.asrc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AutoscaleSettingResourceCollectionPage) Values() []AutoscaleSettingResource { + if page.asrc.IsEmpty() { + return nil + } + return *page.asrc.Value +} + +// Creates a new instance of the AutoscaleSettingResourceCollectionPage type. +func NewAutoscaleSettingResourceCollectionPage(cur AutoscaleSettingResourceCollection, getNextPage func(context.Context, AutoscaleSettingResourceCollection) (AutoscaleSettingResourceCollection, error)) AutoscaleSettingResourceCollectionPage { + return AutoscaleSettingResourceCollectionPage{ + fn: getNextPage, + asrc: cur, + } +} + +// AutoscaleSettingResourcePatch the autoscale setting object for patch operations. +type AutoscaleSettingResourcePatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // AutoscaleSetting - The autoscale setting properties of the update operation. + *AutoscaleSetting `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutoscaleSettingResourcePatch. +func (asrp AutoscaleSettingResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asrp.Tags != nil { + objectMap["tags"] = asrp.Tags + } + if asrp.AutoscaleSetting != nil { + objectMap["properties"] = asrp.AutoscaleSetting + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AutoscaleSettingResourcePatch struct. +func (asrp *AutoscaleSettingResourcePatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + asrp.Tags = tags + } + case "properties": + if v != nil { + var autoscaleSetting AutoscaleSetting + err = json.Unmarshal(*v, &autoscaleSetting) + if err != nil { + return err + } + asrp.AutoscaleSetting = &autoscaleSetting + } + } + } + + return nil +} + +// AzNsActionGroup azure action group +type AzNsActionGroup struct { + // ActionGroup - Azure Action Group reference. + ActionGroup *[]string `json:"actionGroup,omitempty"` + // EmailSubject - Custom subject override for all email ids in Azure action group + EmailSubject *string `json:"emailSubject,omitempty"` + // CustomWebhookPayload - Custom payload to be sent for all webhook URI in Azure action group + CustomWebhookPayload *string `json:"customWebhookPayload,omitempty"` +} + +// AzureAppPushReceiver the Azure mobile App push notification receiver. +type AzureAppPushReceiver struct { + // Name - The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // EmailAddress - The email address registered for the Azure mobile app. + EmailAddress *string `json:"emailAddress,omitempty"` +} + +// AzureFunctionReceiver an azure function receiver. +type AzureFunctionReceiver struct { + // Name - The name of the azure function receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // FunctionAppResourceID - The azure resource id of the function app. + FunctionAppResourceID *string `json:"functionAppResourceId,omitempty"` + // FunctionName - The function name in the function app. + FunctionName *string `json:"functionName,omitempty"` + // HTTPTriggerURL - The http trigger url where http request sent to. + HTTPTriggerURL *string `json:"httpTriggerUrl,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// AzureMonitorMetricsDestination azure Monitor Metrics destination. +type AzureMonitorMetricsDestination struct { + // Name - A friendly name for the destination. + // This name should be unique across all destinations (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// AzureMonitorPrivateLinkScope an Azure Monitor PrivateLinkScope definition. +type AzureMonitorPrivateLinkScope struct { + autorest.Response `json:"-"` + // AzureMonitorPrivateLinkScopeProperties - Properties that define a Azure Monitor PrivateLinkScope resource. + *AzureMonitorPrivateLinkScopeProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for AzureMonitorPrivateLinkScope. +func (ampls AzureMonitorPrivateLinkScope) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ampls.AzureMonitorPrivateLinkScopeProperties != nil { + objectMap["properties"] = ampls.AzureMonitorPrivateLinkScopeProperties + } + if ampls.Location != nil { + objectMap["location"] = ampls.Location + } + if ampls.Tags != nil { + objectMap["tags"] = ampls.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AzureMonitorPrivateLinkScope struct. +func (ampls *AzureMonitorPrivateLinkScope) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var azureMonitorPrivateLinkScopeProperties AzureMonitorPrivateLinkScopeProperties + err = json.Unmarshal(*v, &azureMonitorPrivateLinkScopeProperties) + if err != nil { + return err + } + ampls.AzureMonitorPrivateLinkScopeProperties = &azureMonitorPrivateLinkScopeProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ampls.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ampls.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ampls.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ampls.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ampls.Tags = tags + } + } + } + + return nil +} + +// AzureMonitorPrivateLinkScopeListResult describes the list of Azure Monitor PrivateLinkScope resources. +type AzureMonitorPrivateLinkScopeListResult struct { + autorest.Response `json:"-"` + // Value - List of Azure Monitor PrivateLinkScope definitions. + Value *[]AzureMonitorPrivateLinkScope `json:"value,omitempty"` + // NextLink - The URI to get the next set of Azure Monitor PrivateLinkScope definitions if too many PrivateLinkScopes where returned in the result set. + NextLink *string `json:"nextLink,omitempty"` +} + +// AzureMonitorPrivateLinkScopeListResultIterator provides access to a complete listing of +// AzureMonitorPrivateLinkScope values. +type AzureMonitorPrivateLinkScopeListResultIterator struct { + i int + page AzureMonitorPrivateLinkScopeListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AzureMonitorPrivateLinkScopeListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureMonitorPrivateLinkScopeListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AzureMonitorPrivateLinkScopeListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AzureMonitorPrivateLinkScopeListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AzureMonitorPrivateLinkScopeListResultIterator) Response() AzureMonitorPrivateLinkScopeListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AzureMonitorPrivateLinkScopeListResultIterator) Value() AzureMonitorPrivateLinkScope { + if !iter.page.NotDone() { + return AzureMonitorPrivateLinkScope{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AzureMonitorPrivateLinkScopeListResultIterator type. +func NewAzureMonitorPrivateLinkScopeListResultIterator(page AzureMonitorPrivateLinkScopeListResultPage) AzureMonitorPrivateLinkScopeListResultIterator { + return AzureMonitorPrivateLinkScopeListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (amplslr AzureMonitorPrivateLinkScopeListResult) IsEmpty() bool { + return amplslr.Value == nil || len(*amplslr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (amplslr AzureMonitorPrivateLinkScopeListResult) hasNextLink() bool { + return amplslr.NextLink != nil && len(*amplslr.NextLink) != 0 +} + +// azureMonitorPrivateLinkScopeListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (amplslr AzureMonitorPrivateLinkScopeListResult) azureMonitorPrivateLinkScopeListResultPreparer(ctx context.Context) (*http.Request, error) { + if !amplslr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(amplslr.NextLink))) +} + +// AzureMonitorPrivateLinkScopeListResultPage contains a page of AzureMonitorPrivateLinkScope values. +type AzureMonitorPrivateLinkScopeListResultPage struct { + fn func(context.Context, AzureMonitorPrivateLinkScopeListResult) (AzureMonitorPrivateLinkScopeListResult, error) + amplslr AzureMonitorPrivateLinkScopeListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AzureMonitorPrivateLinkScopeListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureMonitorPrivateLinkScopeListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.amplslr) + if err != nil { + return err + } + page.amplslr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AzureMonitorPrivateLinkScopeListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AzureMonitorPrivateLinkScopeListResultPage) NotDone() bool { + return !page.amplslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AzureMonitorPrivateLinkScopeListResultPage) Response() AzureMonitorPrivateLinkScopeListResult { + return page.amplslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AzureMonitorPrivateLinkScopeListResultPage) Values() []AzureMonitorPrivateLinkScope { + if page.amplslr.IsEmpty() { + return nil + } + return *page.amplslr.Value +} + +// Creates a new instance of the AzureMonitorPrivateLinkScopeListResultPage type. +func NewAzureMonitorPrivateLinkScopeListResultPage(cur AzureMonitorPrivateLinkScopeListResult, getNextPage func(context.Context, AzureMonitorPrivateLinkScopeListResult) (AzureMonitorPrivateLinkScopeListResult, error)) AzureMonitorPrivateLinkScopeListResultPage { + return AzureMonitorPrivateLinkScopeListResultPage{ + fn: getNextPage, + amplslr: cur, + } +} + +// AzureMonitorPrivateLinkScopeProperties properties that define a Azure Monitor PrivateLinkScope resource. +type AzureMonitorPrivateLinkScopeProperties struct { + // ProvisioningState - READ-ONLY; Current state of this PrivateLinkScope: whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Provisioning ,Succeeded, Canceled and Failed. + ProvisioningState *string `json:"provisioningState,omitempty"` + // PrivateEndpointConnections - READ-ONLY; List of private endpoint connections. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureMonitorPrivateLinkScopeProperties. +func (amplsp AzureMonitorPrivateLinkScopeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AzureResource an azure resource object +type AzureResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Kind - READ-ONLY; Azure resource kind + Kind *string `json:"kind,omitempty"` + // Identity - READ-ONLY; Azure resource identity + Identity *string `json:"identity,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for AzureResource. +func (ar AzureResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ar.Location != nil { + objectMap["location"] = ar.Location + } + if ar.Tags != nil { + objectMap["tags"] = ar.Tags + } + return json.Marshal(objectMap) +} + +// BaselineMetadata represents a baseline metadata value. +type BaselineMetadata struct { + // Name - Name of the baseline metadata. + Name *string `json:"name,omitempty"` + // Value - Value of the baseline metadata. + Value *string `json:"value,omitempty"` +} + +// ConfigurationAccessEndpointSpec definition of the endpoint used for accessing configuration. +type ConfigurationAccessEndpointSpec struct { + // Endpoint - READ-ONLY; The endpoint. This property is READ-ONLY. + Endpoint *string `json:"endpoint,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationAccessEndpointSpec. +func (caes ConfigurationAccessEndpointSpec) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Criteria specifies the criteria for converting log to metric. +type Criteria struct { + // MetricName - Name of the metric + MetricName *string `json:"metricName,omitempty"` + // Dimensions - List of Dimensions for creating metric + Dimensions *[]Dimension `json:"dimensions,omitempty"` +} + +// DataCollectionEndpoint definition of data collection endpoint. +type DataCollectionEndpoint struct { + // Description - Description of the data collection endpoint. + Description *string `json:"description,omitempty"` + // ImmutableID - The immutable ID of this data collection endpoint resource. This property is READ-ONLY. + ImmutableID *string `json:"immutableId,omitempty"` + // ConfigurationAccess - The endpoint used by agents to access their configuration. + ConfigurationAccess *DataCollectionEndpointConfigurationAccess `json:"configurationAccess,omitempty"` + // LogsIngestion - The endpoint used by clients to ingest logs. + LogsIngestion *DataCollectionEndpointLogsIngestion `json:"logsIngestion,omitempty"` + // NetworkAcls - Network access control rules for the endpoints. + NetworkAcls *DataCollectionEndpointNetworkAcls `json:"networkAcls,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. This property is READ-ONLY. Possible values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed' + ProvisioningState KnownDataCollectionEndpointProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionEndpoint. +func (dce DataCollectionEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dce.Description != nil { + objectMap["description"] = dce.Description + } + if dce.ImmutableID != nil { + objectMap["immutableId"] = dce.ImmutableID + } + if dce.ConfigurationAccess != nil { + objectMap["configurationAccess"] = dce.ConfigurationAccess + } + if dce.LogsIngestion != nil { + objectMap["logsIngestion"] = dce.LogsIngestion + } + if dce.NetworkAcls != nil { + objectMap["networkAcls"] = dce.NetworkAcls + } + return json.Marshal(objectMap) +} + +// DataCollectionEndpointConfigurationAccess the endpoint used by agents to access their configuration. +type DataCollectionEndpointConfigurationAccess struct { + // Endpoint - READ-ONLY; The endpoint. This property is READ-ONLY. + Endpoint *string `json:"endpoint,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionEndpointConfigurationAccess. +func (dceA DataCollectionEndpointConfigurationAccess) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DataCollectionEndpointLogsIngestion the endpoint used by clients to ingest logs. +type DataCollectionEndpointLogsIngestion struct { + // Endpoint - READ-ONLY; The endpoint. This property is READ-ONLY. + Endpoint *string `json:"endpoint,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionEndpointLogsIngestion. +func (dceI DataCollectionEndpointLogsIngestion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DataCollectionEndpointNetworkAcls network access control rules for the endpoints. +type DataCollectionEndpointNetworkAcls struct { + // PublicNetworkAccess - The configuration to set whether network access from public internet to the endpoints are allowed. Possible values include: 'KnownPublicNetworkAccessOptionsEnabled', 'KnownPublicNetworkAccessOptionsDisabled' + PublicNetworkAccess KnownPublicNetworkAccessOptions `json:"publicNetworkAccess,omitempty"` +} + +// DataCollectionEndpointResource definition of ARM tracked top level resource. +type DataCollectionEndpointResource struct { + autorest.Response `json:"-"` + // DataCollectionEndpointResourceProperties - Resource properties. + *DataCollectionEndpointResourceProperties `json:"properties,omitempty"` + // Location - The geo-location where the resource lives. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Kind - The kind of the resource. Possible values include: 'Linux', 'Windows' + Kind KnownDataCollectionEndpointResourceKind `json:"kind,omitempty"` + // ID - READ-ONLY; Fully qualified ID of the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // Etag - READ-ONLY; Resource entity tag (ETag). + Etag *string `json:"etag,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *DataCollectionEndpointResourceSystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionEndpointResource. +func (dcer DataCollectionEndpointResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcer.DataCollectionEndpointResourceProperties != nil { + objectMap["properties"] = dcer.DataCollectionEndpointResourceProperties + } + if dcer.Location != nil { + objectMap["location"] = dcer.Location + } + if dcer.Tags != nil { + objectMap["tags"] = dcer.Tags + } + if dcer.Kind != "" { + objectMap["kind"] = dcer.Kind + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataCollectionEndpointResource struct. +func (dcer *DataCollectionEndpointResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dataCollectionEndpointResourceProperties DataCollectionEndpointResourceProperties + err = json.Unmarshal(*v, &dataCollectionEndpointResourceProperties) + if err != nil { + return err + } + dcer.DataCollectionEndpointResourceProperties = &dataCollectionEndpointResourceProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dcer.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dcer.Tags = tags + } + case "kind": + if v != nil { + var kind KnownDataCollectionEndpointResourceKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dcer.Kind = kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dcer.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcer.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dcer.Type = &typeVar + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + dcer.Etag = &etag + } + case "systemData": + if v != nil { + var systemData DataCollectionEndpointResourceSystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + dcer.SystemData = &systemData + } + } + } + + return nil +} + +// DataCollectionEndpointResourceListResult a pageable list of resources. +type DataCollectionEndpointResourceListResult struct { + autorest.Response `json:"-"` + // Value - A list of resources. + Value *[]DataCollectionEndpointResource `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DataCollectionEndpointResourceListResultIterator provides access to a complete listing of +// DataCollectionEndpointResource values. +type DataCollectionEndpointResourceListResultIterator struct { + i int + page DataCollectionEndpointResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DataCollectionEndpointResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DataCollectionEndpointResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DataCollectionEndpointResourceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DataCollectionEndpointResourceListResultIterator) Response() DataCollectionEndpointResourceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DataCollectionEndpointResourceListResultIterator) Value() DataCollectionEndpointResource { + if !iter.page.NotDone() { + return DataCollectionEndpointResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DataCollectionEndpointResourceListResultIterator type. +func NewDataCollectionEndpointResourceListResultIterator(page DataCollectionEndpointResourceListResultPage) DataCollectionEndpointResourceListResultIterator { + return DataCollectionEndpointResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dcerlr DataCollectionEndpointResourceListResult) IsEmpty() bool { + return dcerlr.Value == nil || len(*dcerlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dcerlr DataCollectionEndpointResourceListResult) hasNextLink() bool { + return dcerlr.NextLink != nil && len(*dcerlr.NextLink) != 0 +} + +// dataCollectionEndpointResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dcerlr DataCollectionEndpointResourceListResult) dataCollectionEndpointResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dcerlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dcerlr.NextLink))) +} + +// DataCollectionEndpointResourceListResultPage contains a page of DataCollectionEndpointResource values. +type DataCollectionEndpointResourceListResultPage struct { + fn func(context.Context, DataCollectionEndpointResourceListResult) (DataCollectionEndpointResourceListResult, error) + dcerlr DataCollectionEndpointResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DataCollectionEndpointResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dcerlr) + if err != nil { + return err + } + page.dcerlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DataCollectionEndpointResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DataCollectionEndpointResourceListResultPage) NotDone() bool { + return !page.dcerlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DataCollectionEndpointResourceListResultPage) Response() DataCollectionEndpointResourceListResult { + return page.dcerlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DataCollectionEndpointResourceListResultPage) Values() []DataCollectionEndpointResource { + if page.dcerlr.IsEmpty() { + return nil + } + return *page.dcerlr.Value +} + +// Creates a new instance of the DataCollectionEndpointResourceListResultPage type. +func NewDataCollectionEndpointResourceListResultPage(cur DataCollectionEndpointResourceListResult, getNextPage func(context.Context, DataCollectionEndpointResourceListResult) (DataCollectionEndpointResourceListResult, error)) DataCollectionEndpointResourceListResultPage { + return DataCollectionEndpointResourceListResultPage{ + fn: getNextPage, + dcerlr: cur, + } +} + +// DataCollectionEndpointResourceProperties resource properties. +type DataCollectionEndpointResourceProperties struct { + // Description - Description of the data collection endpoint. + Description *string `json:"description,omitempty"` + // ImmutableID - The immutable ID of this data collection endpoint resource. This property is READ-ONLY. + ImmutableID *string `json:"immutableId,omitempty"` + // ConfigurationAccess - The endpoint used by agents to access their configuration. + ConfigurationAccess *DataCollectionEndpointConfigurationAccess `json:"configurationAccess,omitempty"` + // LogsIngestion - The endpoint used by clients to ingest logs. + LogsIngestion *DataCollectionEndpointLogsIngestion `json:"logsIngestion,omitempty"` + // NetworkAcls - Network access control rules for the endpoints. + NetworkAcls *DataCollectionEndpointNetworkAcls `json:"networkAcls,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. This property is READ-ONLY. Possible values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed' + ProvisioningState KnownDataCollectionEndpointProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionEndpointResourceProperties. +func (dcer DataCollectionEndpointResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcer.Description != nil { + objectMap["description"] = dcer.Description + } + if dcer.ImmutableID != nil { + objectMap["immutableId"] = dcer.ImmutableID + } + if dcer.ConfigurationAccess != nil { + objectMap["configurationAccess"] = dcer.ConfigurationAccess + } + if dcer.LogsIngestion != nil { + objectMap["logsIngestion"] = dcer.LogsIngestion + } + if dcer.NetworkAcls != nil { + objectMap["networkAcls"] = dcer.NetworkAcls + } + return json.Marshal(objectMap) +} + +// DataCollectionEndpointResourceSystemData metadata pertaining to creation and last modification of the +// resource. +type DataCollectionEndpointResourceSystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// DataCollectionRule definition of what monitoring data to collect and where that data should be sent. +type DataCollectionRule struct { + // Description - Description of the data collection rule. + Description *string `json:"description,omitempty"` + // ImmutableID - READ-ONLY; The immutable ID of this data collection rule. This property is READ-ONLY. + ImmutableID *string `json:"immutableId,omitempty"` + // DataSources - The specification of data sources. + // This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. + DataSources *DataCollectionRuleDataSources `json:"dataSources,omitempty"` + // Destinations - The specification of destinations. + Destinations *DataCollectionRuleDestinations `json:"destinations,omitempty"` + // DataFlows - The specification of data flows. + DataFlows *[]DataFlow `json:"dataFlows,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. Possible values include: 'KnownDataCollectionRuleProvisioningStateCreating', 'KnownDataCollectionRuleProvisioningStateUpdating', 'KnownDataCollectionRuleProvisioningStateDeleting', 'KnownDataCollectionRuleProvisioningStateSucceeded', 'KnownDataCollectionRuleProvisioningStateFailed' + ProvisioningState KnownDataCollectionRuleProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRule. +func (dcr DataCollectionRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcr.Description != nil { + objectMap["description"] = dcr.Description + } + if dcr.DataSources != nil { + objectMap["dataSources"] = dcr.DataSources + } + if dcr.Destinations != nil { + objectMap["destinations"] = dcr.Destinations + } + if dcr.DataFlows != nil { + objectMap["dataFlows"] = dcr.DataFlows + } + return json.Marshal(objectMap) +} + +// DataCollectionRuleAssociation definition of association of a data collection rule with a monitored Azure +// resource. +type DataCollectionRuleAssociation struct { + // Description - Description of the association. + Description *string `json:"description,omitempty"` + // DataCollectionRuleID - The resource ID of the data collection rule that is to be associated. + DataCollectionRuleID *string `json:"dataCollectionRuleId,omitempty"` + // DataCollectionEndpointID - The resource ID of the data collection endpoint that is to be associated. + DataCollectionEndpointID *string `json:"dataCollectionEndpointId,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. Possible values include: 'KnownDataCollectionRuleAssociationProvisioningStateCreating', 'KnownDataCollectionRuleAssociationProvisioningStateUpdating', 'KnownDataCollectionRuleAssociationProvisioningStateDeleting', 'KnownDataCollectionRuleAssociationProvisioningStateSucceeded', 'KnownDataCollectionRuleAssociationProvisioningStateFailed' + ProvisioningState KnownDataCollectionRuleAssociationProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRuleAssociation. +func (dcra DataCollectionRuleAssociation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcra.Description != nil { + objectMap["description"] = dcra.Description + } + if dcra.DataCollectionRuleID != nil { + objectMap["dataCollectionRuleId"] = dcra.DataCollectionRuleID + } + if dcra.DataCollectionEndpointID != nil { + objectMap["dataCollectionEndpointId"] = dcra.DataCollectionEndpointID + } + return json.Marshal(objectMap) +} + +// DataCollectionRuleAssociationProxyOnlyResource definition of generic ARM proxy resource. +type DataCollectionRuleAssociationProxyOnlyResource struct { + autorest.Response `json:"-"` + // DataCollectionRuleAssociationProxyOnlyResourceProperties - Resource properties. + *DataCollectionRuleAssociationProxyOnlyResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified ID of the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // Etag - READ-ONLY; Resource entity tag (ETag). + Etag *string `json:"etag,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *DataCollectionRuleAssociationProxyOnlyResourceSystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRuleAssociationProxyOnlyResource. +func (dcrapor DataCollectionRuleAssociationProxyOnlyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcrapor.DataCollectionRuleAssociationProxyOnlyResourceProperties != nil { + objectMap["properties"] = dcrapor.DataCollectionRuleAssociationProxyOnlyResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataCollectionRuleAssociationProxyOnlyResource struct. +func (dcrapor *DataCollectionRuleAssociationProxyOnlyResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dataCollectionRuleAssociationProxyOnlyResourceProperties DataCollectionRuleAssociationProxyOnlyResourceProperties + err = json.Unmarshal(*v, &dataCollectionRuleAssociationProxyOnlyResourceProperties) + if err != nil { + return err + } + dcrapor.DataCollectionRuleAssociationProxyOnlyResourceProperties = &dataCollectionRuleAssociationProxyOnlyResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dcrapor.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcrapor.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dcrapor.Type = &typeVar + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + dcrapor.Etag = &etag + } + case "systemData": + if v != nil { + var systemData DataCollectionRuleAssociationProxyOnlyResourceSystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + dcrapor.SystemData = &systemData + } + } + } + + return nil +} + +// DataCollectionRuleAssociationProxyOnlyResourceListResult a pageable list of resources. +type DataCollectionRuleAssociationProxyOnlyResourceListResult struct { + autorest.Response `json:"-"` + // Value - A list of resources. + Value *[]DataCollectionRuleAssociationProxyOnlyResource `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DataCollectionRuleAssociationProxyOnlyResourceListResultIterator provides access to a complete listing +// of DataCollectionRuleAssociationProxyOnlyResource values. +type DataCollectionRuleAssociationProxyOnlyResourceListResultIterator struct { + i int + page DataCollectionRuleAssociationProxyOnlyResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DataCollectionRuleAssociationProxyOnlyResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationProxyOnlyResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DataCollectionRuleAssociationProxyOnlyResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DataCollectionRuleAssociationProxyOnlyResourceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DataCollectionRuleAssociationProxyOnlyResourceListResultIterator) Response() DataCollectionRuleAssociationProxyOnlyResourceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DataCollectionRuleAssociationProxyOnlyResourceListResultIterator) Value() DataCollectionRuleAssociationProxyOnlyResource { + if !iter.page.NotDone() { + return DataCollectionRuleAssociationProxyOnlyResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DataCollectionRuleAssociationProxyOnlyResourceListResultIterator type. +func NewDataCollectionRuleAssociationProxyOnlyResourceListResultIterator(page DataCollectionRuleAssociationProxyOnlyResourceListResultPage) DataCollectionRuleAssociationProxyOnlyResourceListResultIterator { + return DataCollectionRuleAssociationProxyOnlyResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dcraporlr DataCollectionRuleAssociationProxyOnlyResourceListResult) IsEmpty() bool { + return dcraporlr.Value == nil || len(*dcraporlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dcraporlr DataCollectionRuleAssociationProxyOnlyResourceListResult) hasNextLink() bool { + return dcraporlr.NextLink != nil && len(*dcraporlr.NextLink) != 0 +} + +// dataCollectionRuleAssociationProxyOnlyResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dcraporlr DataCollectionRuleAssociationProxyOnlyResourceListResult) dataCollectionRuleAssociationProxyOnlyResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dcraporlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dcraporlr.NextLink))) +} + +// DataCollectionRuleAssociationProxyOnlyResourceListResultPage contains a page of +// DataCollectionRuleAssociationProxyOnlyResource values. +type DataCollectionRuleAssociationProxyOnlyResourceListResultPage struct { + fn func(context.Context, DataCollectionRuleAssociationProxyOnlyResourceListResult) (DataCollectionRuleAssociationProxyOnlyResourceListResult, error) + dcraporlr DataCollectionRuleAssociationProxyOnlyResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DataCollectionRuleAssociationProxyOnlyResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationProxyOnlyResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dcraporlr) + if err != nil { + return err + } + page.dcraporlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DataCollectionRuleAssociationProxyOnlyResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DataCollectionRuleAssociationProxyOnlyResourceListResultPage) NotDone() bool { + return !page.dcraporlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DataCollectionRuleAssociationProxyOnlyResourceListResultPage) Response() DataCollectionRuleAssociationProxyOnlyResourceListResult { + return page.dcraporlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DataCollectionRuleAssociationProxyOnlyResourceListResultPage) Values() []DataCollectionRuleAssociationProxyOnlyResource { + if page.dcraporlr.IsEmpty() { + return nil + } + return *page.dcraporlr.Value +} + +// Creates a new instance of the DataCollectionRuleAssociationProxyOnlyResourceListResultPage type. +func NewDataCollectionRuleAssociationProxyOnlyResourceListResultPage(cur DataCollectionRuleAssociationProxyOnlyResourceListResult, getNextPage func(context.Context, DataCollectionRuleAssociationProxyOnlyResourceListResult) (DataCollectionRuleAssociationProxyOnlyResourceListResult, error)) DataCollectionRuleAssociationProxyOnlyResourceListResultPage { + return DataCollectionRuleAssociationProxyOnlyResourceListResultPage{ + fn: getNextPage, + dcraporlr: cur, + } +} + +// DataCollectionRuleAssociationProxyOnlyResourceProperties resource properties. +type DataCollectionRuleAssociationProxyOnlyResourceProperties struct { + // Description - Description of the association. + Description *string `json:"description,omitempty"` + // DataCollectionRuleID - The resource ID of the data collection rule that is to be associated. + DataCollectionRuleID *string `json:"dataCollectionRuleId,omitempty"` + // DataCollectionEndpointID - The resource ID of the data collection endpoint that is to be associated. + DataCollectionEndpointID *string `json:"dataCollectionEndpointId,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. Possible values include: 'KnownDataCollectionRuleAssociationProvisioningStateCreating', 'KnownDataCollectionRuleAssociationProvisioningStateUpdating', 'KnownDataCollectionRuleAssociationProvisioningStateDeleting', 'KnownDataCollectionRuleAssociationProvisioningStateSucceeded', 'KnownDataCollectionRuleAssociationProvisioningStateFailed' + ProvisioningState KnownDataCollectionRuleAssociationProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRuleAssociationProxyOnlyResourceProperties. +func (dcrapor DataCollectionRuleAssociationProxyOnlyResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcrapor.Description != nil { + objectMap["description"] = dcrapor.Description + } + if dcrapor.DataCollectionRuleID != nil { + objectMap["dataCollectionRuleId"] = dcrapor.DataCollectionRuleID + } + if dcrapor.DataCollectionEndpointID != nil { + objectMap["dataCollectionEndpointId"] = dcrapor.DataCollectionEndpointID + } + return json.Marshal(objectMap) +} + +// DataCollectionRuleAssociationProxyOnlyResourceSystemData metadata pertaining to creation and last +// modification of the resource. +type DataCollectionRuleAssociationProxyOnlyResourceSystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// DataCollectionRuleDataSources the specification of data sources. +// This property is optional and can be omitted if the rule is meant to be used via direct calls to the +// provisioned endpoint. +type DataCollectionRuleDataSources struct { + // PerformanceCounters - The list of performance counter data source configurations. + PerformanceCounters *[]PerfCounterDataSource `json:"performanceCounters,omitempty"` + // WindowsEventLogs - The list of Windows Event Log data source configurations. + WindowsEventLogs *[]WindowsEventLogDataSource `json:"windowsEventLogs,omitempty"` + // Syslog - The list of Syslog data source configurations. + Syslog *[]SyslogDataSource `json:"syslog,omitempty"` + // Extensions - The list of Azure VM extension data source configurations. + Extensions *[]ExtensionDataSource `json:"extensions,omitempty"` +} + +// DataCollectionRuleDestinations the specification of destinations. +type DataCollectionRuleDestinations struct { + // LogAnalytics - List of Log Analytics destinations. + LogAnalytics *[]LogAnalyticsDestination `json:"logAnalytics,omitempty"` + // AzureMonitorMetrics - Azure Monitor Metrics destination. + AzureMonitorMetrics *DestinationsSpecAzureMonitorMetrics `json:"azureMonitorMetrics,omitempty"` +} + +// DataCollectionRuleResource definition of ARM tracked top level resource. +type DataCollectionRuleResource struct { + autorest.Response `json:"-"` + // DataCollectionRuleResourceProperties - Resource properties. + *DataCollectionRuleResourceProperties `json:"properties,omitempty"` + // Location - The geo-location where the resource lives. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Kind - The kind of the resource. Possible values include: 'KnownDataCollectionRuleResourceKindLinux', 'KnownDataCollectionRuleResourceKindWindows' + Kind KnownDataCollectionRuleResourceKind `json:"kind,omitempty"` + // ID - READ-ONLY; Fully qualified ID of the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // Etag - READ-ONLY; Resource entity tag (ETag). + Etag *string `json:"etag,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *DataCollectionRuleResourceSystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRuleResource. +func (dcrr DataCollectionRuleResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcrr.DataCollectionRuleResourceProperties != nil { + objectMap["properties"] = dcrr.DataCollectionRuleResourceProperties + } + if dcrr.Location != nil { + objectMap["location"] = dcrr.Location + } + if dcrr.Tags != nil { + objectMap["tags"] = dcrr.Tags + } + if dcrr.Kind != "" { + objectMap["kind"] = dcrr.Kind + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataCollectionRuleResource struct. +func (dcrr *DataCollectionRuleResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dataCollectionRuleResourceProperties DataCollectionRuleResourceProperties + err = json.Unmarshal(*v, &dataCollectionRuleResourceProperties) + if err != nil { + return err + } + dcrr.DataCollectionRuleResourceProperties = &dataCollectionRuleResourceProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dcrr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dcrr.Tags = tags + } + case "kind": + if v != nil { + var kind KnownDataCollectionRuleResourceKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dcrr.Kind = kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dcrr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcrr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dcrr.Type = &typeVar + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + dcrr.Etag = &etag + } + case "systemData": + if v != nil { + var systemData DataCollectionRuleResourceSystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + dcrr.SystemData = &systemData + } + } + } + + return nil +} + +// DataCollectionRuleResourceListResult a pageable list of resources. +type DataCollectionRuleResourceListResult struct { + autorest.Response `json:"-"` + // Value - A list of resources. + Value *[]DataCollectionRuleResource `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DataCollectionRuleResourceListResultIterator provides access to a complete listing of +// DataCollectionRuleResource values. +type DataCollectionRuleResourceListResultIterator struct { + i int + page DataCollectionRuleResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DataCollectionRuleResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DataCollectionRuleResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DataCollectionRuleResourceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DataCollectionRuleResourceListResultIterator) Response() DataCollectionRuleResourceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DataCollectionRuleResourceListResultIterator) Value() DataCollectionRuleResource { + if !iter.page.NotDone() { + return DataCollectionRuleResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DataCollectionRuleResourceListResultIterator type. +func NewDataCollectionRuleResourceListResultIterator(page DataCollectionRuleResourceListResultPage) DataCollectionRuleResourceListResultIterator { + return DataCollectionRuleResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dcrrlr DataCollectionRuleResourceListResult) IsEmpty() bool { + return dcrrlr.Value == nil || len(*dcrrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dcrrlr DataCollectionRuleResourceListResult) hasNextLink() bool { + return dcrrlr.NextLink != nil && len(*dcrrlr.NextLink) != 0 +} + +// dataCollectionRuleResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dcrrlr DataCollectionRuleResourceListResult) dataCollectionRuleResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dcrrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dcrrlr.NextLink))) +} + +// DataCollectionRuleResourceListResultPage contains a page of DataCollectionRuleResource values. +type DataCollectionRuleResourceListResultPage struct { + fn func(context.Context, DataCollectionRuleResourceListResult) (DataCollectionRuleResourceListResult, error) + dcrrlr DataCollectionRuleResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DataCollectionRuleResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dcrrlr) + if err != nil { + return err + } + page.dcrrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DataCollectionRuleResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DataCollectionRuleResourceListResultPage) NotDone() bool { + return !page.dcrrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DataCollectionRuleResourceListResultPage) Response() DataCollectionRuleResourceListResult { + return page.dcrrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DataCollectionRuleResourceListResultPage) Values() []DataCollectionRuleResource { + if page.dcrrlr.IsEmpty() { + return nil + } + return *page.dcrrlr.Value +} + +// Creates a new instance of the DataCollectionRuleResourceListResultPage type. +func NewDataCollectionRuleResourceListResultPage(cur DataCollectionRuleResourceListResult, getNextPage func(context.Context, DataCollectionRuleResourceListResult) (DataCollectionRuleResourceListResult, error)) DataCollectionRuleResourceListResultPage { + return DataCollectionRuleResourceListResultPage{ + fn: getNextPage, + dcrrlr: cur, + } +} + +// DataCollectionRuleResourceProperties resource properties. +type DataCollectionRuleResourceProperties struct { + // Description - Description of the data collection rule. + Description *string `json:"description,omitempty"` + // ImmutableID - READ-ONLY; The immutable ID of this data collection rule. This property is READ-ONLY. + ImmutableID *string `json:"immutableId,omitempty"` + // DataSources - The specification of data sources. + // This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. + DataSources *DataCollectionRuleDataSources `json:"dataSources,omitempty"` + // Destinations - The specification of destinations. + Destinations *DataCollectionRuleDestinations `json:"destinations,omitempty"` + // DataFlows - The specification of data flows. + DataFlows *[]DataFlow `json:"dataFlows,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. Possible values include: 'KnownDataCollectionRuleProvisioningStateCreating', 'KnownDataCollectionRuleProvisioningStateUpdating', 'KnownDataCollectionRuleProvisioningStateDeleting', 'KnownDataCollectionRuleProvisioningStateSucceeded', 'KnownDataCollectionRuleProvisioningStateFailed' + ProvisioningState KnownDataCollectionRuleProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRuleResourceProperties. +func (dcrr DataCollectionRuleResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcrr.Description != nil { + objectMap["description"] = dcrr.Description + } + if dcrr.DataSources != nil { + objectMap["dataSources"] = dcrr.DataSources + } + if dcrr.Destinations != nil { + objectMap["destinations"] = dcrr.Destinations + } + if dcrr.DataFlows != nil { + objectMap["dataFlows"] = dcrr.DataFlows + } + return json.Marshal(objectMap) +} + +// DataCollectionRuleResourceSystemData metadata pertaining to creation and last modification of the +// resource. +type DataCollectionRuleResourceSystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// DataContainer information about a container with data for a given resource. +type DataContainer struct { + // Workspace - Log Analytics workspace information. + Workspace *WorkspaceInfo `json:"workspace,omitempty"` +} + +// DataFlow definition of which streams are sent to which destinations. +type DataFlow struct { + // Streams - List of streams for this data flow. + Streams *[]KnownDataFlowStreams `json:"streams,omitempty"` + // Destinations - List of destinations for this data flow. + Destinations *[]string `json:"destinations,omitempty"` +} + +// DataSourcesSpec specification of data sources that will be collected. +type DataSourcesSpec struct { + // PerformanceCounters - The list of performance counter data source configurations. + PerformanceCounters *[]PerfCounterDataSource `json:"performanceCounters,omitempty"` + // WindowsEventLogs - The list of Windows Event Log data source configurations. + WindowsEventLogs *[]WindowsEventLogDataSource `json:"windowsEventLogs,omitempty"` + // Syslog - The list of Syslog data source configurations. + Syslog *[]SyslogDataSource `json:"syslog,omitempty"` + // Extensions - The list of Azure VM extension data source configurations. + Extensions *[]ExtensionDataSource `json:"extensions,omitempty"` +} + +// DestinationsSpec specification of destinations that can be used in data flows. +type DestinationsSpec struct { + // LogAnalytics - List of Log Analytics destinations. + LogAnalytics *[]LogAnalyticsDestination `json:"logAnalytics,omitempty"` + // AzureMonitorMetrics - Azure Monitor Metrics destination. + AzureMonitorMetrics *DestinationsSpecAzureMonitorMetrics `json:"azureMonitorMetrics,omitempty"` +} + +// DestinationsSpecAzureMonitorMetrics azure Monitor Metrics destination. +type DestinationsSpecAzureMonitorMetrics struct { + // Name - A friendly name for the destination. + // This name should be unique across all destinations (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// DiagnosticSettings the diagnostic settings. +type DiagnosticSettings struct { + // StorageAccountID - The resource ID of the storage account to which you would like to send Diagnostic Logs. + StorageAccountID *string `json:"storageAccountId,omitempty"` + // ServiceBusRuleID - The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. + ServiceBusRuleID *string `json:"serviceBusRuleId,omitempty"` + // EventHubAuthorizationRuleID - The resource Id for the event hub authorization rule. + EventHubAuthorizationRuleID *string `json:"eventHubAuthorizationRuleId,omitempty"` + // EventHubName - The name of the event hub. If none is specified, the default event hub will be selected. + EventHubName *string `json:"eventHubName,omitempty"` + // Metrics - The list of metric settings. + Metrics *[]MetricSettings `json:"metrics,omitempty"` + // Logs - The list of logs settings. + Logs *[]LogSettings `json:"logs,omitempty"` + // WorkspaceID - The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + WorkspaceID *string `json:"workspaceId,omitempty"` + // LogAnalyticsDestinationType - A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows: _. Possible values are: Dedicated and null (null is default.) + LogAnalyticsDestinationType *string `json:"logAnalyticsDestinationType,omitempty"` +} + +// DiagnosticSettingsCategory the diagnostic settings Category. +type DiagnosticSettingsCategory struct { + // CategoryType - The type of the diagnostic settings category. Possible values include: 'Metrics', 'Logs' + CategoryType CategoryType `json:"categoryType,omitempty"` +} + +// DiagnosticSettingsCategoryResource the diagnostic settings category resource. +type DiagnosticSettingsCategoryResource struct { + autorest.Response `json:"-"` + // DiagnosticSettingsCategory - The properties of a Diagnostic Settings Category. + *DiagnosticSettingsCategory `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DiagnosticSettingsCategoryResource. +func (dscr DiagnosticSettingsCategoryResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dscr.DiagnosticSettingsCategory != nil { + objectMap["properties"] = dscr.DiagnosticSettingsCategory + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DiagnosticSettingsCategoryResource struct. +func (dscr *DiagnosticSettingsCategoryResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var diagnosticSettingsCategory DiagnosticSettingsCategory + err = json.Unmarshal(*v, &diagnosticSettingsCategory) + if err != nil { + return err + } + dscr.DiagnosticSettingsCategory = &diagnosticSettingsCategory + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dscr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dscr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dscr.Type = &typeVar + } + } + } + + return nil +} + +// DiagnosticSettingsCategoryResourceCollection represents a collection of diagnostic setting category +// resources. +type DiagnosticSettingsCategoryResourceCollection struct { + autorest.Response `json:"-"` + // Value - The collection of diagnostic settings category resources. + Value *[]DiagnosticSettingsCategoryResource `json:"value,omitempty"` +} + +// DiagnosticSettingsResource the diagnostic setting resource. +type DiagnosticSettingsResource struct { + autorest.Response `json:"-"` + // DiagnosticSettings - Properties of a Diagnostic Settings Resource. + *DiagnosticSettings `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DiagnosticSettingsResource. +func (dsr DiagnosticSettingsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dsr.DiagnosticSettings != nil { + objectMap["properties"] = dsr.DiagnosticSettings + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DiagnosticSettingsResource struct. +func (dsr *DiagnosticSettingsResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var diagnosticSettings DiagnosticSettings + err = json.Unmarshal(*v, &diagnosticSettings) + if err != nil { + return err + } + dsr.DiagnosticSettings = &diagnosticSettings + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dsr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dsr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dsr.Type = &typeVar + } + } + } + + return nil +} + +// DiagnosticSettingsResourceCollection represents a collection of alert rule resources. +type DiagnosticSettingsResourceCollection struct { + autorest.Response `json:"-"` + // Value - The collection of diagnostic settings resources;. + Value *[]DiagnosticSettingsResource `json:"value,omitempty"` +} + +// Dimension specifies the criteria for converting log to metric. +type Dimension struct { + // Name - Name of the dimension + Name *string `json:"name,omitempty"` + // Operator - Operator for dimension values + Operator *string `json:"operator,omitempty"` + // Values - List of dimension values + Values *[]string `json:"values,omitempty"` +} + +// DynamicMetricCriteria criterion for dynamic threshold. +type DynamicMetricCriteria struct { + // Operator - The operator used to compare the metric value against the threshold. Possible values include: 'DynamicThresholdOperatorGreaterThan', 'DynamicThresholdOperatorLessThan', 'DynamicThresholdOperatorGreaterOrLessThan' + Operator DynamicThresholdOperator `json:"operator,omitempty"` + // AlertSensitivity - The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Possible values include: 'DynamicThresholdSensitivityLow', 'DynamicThresholdSensitivityMedium', 'DynamicThresholdSensitivityHigh' + AlertSensitivity DynamicThresholdSensitivity `json:"alertSensitivity,omitempty"` + // FailingPeriods - The minimum number of violations required within the selected lookback time window required to raise an alert. + FailingPeriods *DynamicThresholdFailingPeriods `json:"failingPeriods,omitempty"` + // IgnoreDataBefore - Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) + IgnoreDataBefore *date.Time `json:"ignoreDataBefore,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal' + TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. + SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' + CriterionType CriterionType `json:"criterionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) MarshalJSON() ([]byte, error) { + dmc.CriterionType = CriterionTypeDynamicThresholdCriterion + objectMap := make(map[string]interface{}) + if dmc.Operator != "" { + objectMap["operator"] = dmc.Operator + } + if dmc.AlertSensitivity != "" { + objectMap["alertSensitivity"] = dmc.AlertSensitivity + } + if dmc.FailingPeriods != nil { + objectMap["failingPeriods"] = dmc.FailingPeriods + } + if dmc.IgnoreDataBefore != nil { + objectMap["ignoreDataBefore"] = dmc.IgnoreDataBefore + } + if dmc.Name != nil { + objectMap["name"] = dmc.Name + } + if dmc.MetricName != nil { + objectMap["metricName"] = dmc.MetricName + } + if dmc.MetricNamespace != nil { + objectMap["metricNamespace"] = dmc.MetricNamespace + } + if dmc.TimeAggregation != "" { + objectMap["timeAggregation"] = dmc.TimeAggregation + } + if dmc.Dimensions != nil { + objectMap["dimensions"] = dmc.Dimensions + } + if dmc.SkipMetricValidation != nil { + objectMap["skipMetricValidation"] = dmc.SkipMetricValidation + } + if dmc.CriterionType != "" { + objectMap["criterionType"] = dmc.CriterionType + } + for k, v := range dmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { + return nil, false +} + +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return &dmc, true +} + +// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { + return nil, false +} + +// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) { + return &dmc, true +} + +// UnmarshalJSON is the custom unmarshaler for DynamicMetricCriteria struct. +func (dmc *DynamicMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "operator": + if v != nil { + var operator DynamicThresholdOperator + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + dmc.Operator = operator + } + case "alertSensitivity": + if v != nil { + var alertSensitivity DynamicThresholdSensitivity + err = json.Unmarshal(*v, &alertSensitivity) + if err != nil { + return err + } + dmc.AlertSensitivity = alertSensitivity + } + case "failingPeriods": + if v != nil { + var failingPeriods DynamicThresholdFailingPeriods + err = json.Unmarshal(*v, &failingPeriods) + if err != nil { + return err + } + dmc.FailingPeriods = &failingPeriods + } + case "ignoreDataBefore": + if v != nil { + var ignoreDataBefore date.Time + err = json.Unmarshal(*v, &ignoreDataBefore) + if err != nil { + return err + } + dmc.IgnoreDataBefore = &ignoreDataBefore + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if dmc.AdditionalProperties == nil { + dmc.AdditionalProperties = make(map[string]interface{}) + } + dmc.AdditionalProperties[k] = additionalProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + dmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + dmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation AggregationTypeEnum + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + dmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + dmc.Dimensions = &dimensions + } + case "skipMetricValidation": + if v != nil { + var skipMetricValidation bool + err = json.Unmarshal(*v, &skipMetricValidation) + if err != nil { + return err + } + dmc.SkipMetricValidation = &skipMetricValidation + } + case "criterionType": + if v != nil { + var criterionType CriterionType + err = json.Unmarshal(*v, &criterionType) + if err != nil { + return err + } + dmc.CriterionType = criterionType + } + } + } + + return nil +} + +// DynamicThresholdFailingPeriods the minimum number of violations required within the selected lookback +// time window required to raise an alert. +type DynamicThresholdFailingPeriods struct { + // NumberOfEvaluationPeriods - The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + NumberOfEvaluationPeriods *float64 `json:"numberOfEvaluationPeriods,omitempty"` + // MinFailingPeriodsToAlert - The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. + MinFailingPeriodsToAlert *float64 `json:"minFailingPeriodsToAlert,omitempty"` +} + +// EmailNotification email notification of an autoscale event. +type EmailNotification struct { + // SendToSubscriptionAdministrator - a value indicating whether to send email to subscription administrator. + SendToSubscriptionAdministrator *bool `json:"sendToSubscriptionAdministrator,omitempty"` + // SendToSubscriptionCoAdministrators - a value indicating whether to send email to subscription co-administrators. + SendToSubscriptionCoAdministrators *bool `json:"sendToSubscriptionCoAdministrators,omitempty"` + // CustomEmails - the custom e-mails list. This value can be null or empty, in which case this attribute will be ignored. + CustomEmails *[]string `json:"customEmails,omitempty"` +} + +// EmailReceiver an email receiver. +type EmailReceiver struct { + // Name - The name of the email receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // EmailAddress - The email address of this receiver. + EmailAddress *string `json:"emailAddress,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` + // Status - READ-ONLY; The receiver status of the e-mail. Possible values include: 'ReceiverStatusNotSpecified', 'ReceiverStatusEnabled', 'ReceiverStatusDisabled' + Status ReceiverStatus `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for EmailReceiver. +func (er EmailReceiver) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if er.Name != nil { + objectMap["name"] = er.Name + } + if er.EmailAddress != nil { + objectMap["emailAddress"] = er.EmailAddress + } + if er.UseCommonAlertSchema != nil { + objectMap["useCommonAlertSchema"] = er.UseCommonAlertSchema + } + return json.Marshal(objectMap) +} + +// EnableRequest describes a receiver that should be resubscribed. +type EnableRequest struct { + // ReceiverName - The name of the receiver to resubscribe. + ReceiverName *string `json:"receiverName,omitempty"` +} + +// Error error details. +type Error struct { + // Code - Error code identifying the specific error. + Code *string `json:"code,omitempty"` + // Message - Error message in the caller's locale. + Message *string `json:"message,omitempty"` +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorContract describes the format of Error response. +type ErrorContract struct { + // Error - The error details. + Error *ErrorResponse `json:"error,omitempty"` +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse describes the format of Error response. +type ErrorResponse struct { + // Code - Error code + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// ErrorResponseCommon the resource management error response. +type ErrorResponseCommon struct { + // Details - READ-ONLY; The error details. + Details *[]ErrorResponseCommon `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + // Code - Error code + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorResponseCommon. +func (erc ErrorResponseCommon) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if erc.Code != nil { + objectMap["code"] = erc.Code + } + if erc.Message != nil { + objectMap["message"] = erc.Message + } + return json.Marshal(objectMap) +} + +// ErrorResponseCommonV2 common error response for all Azure Resource Manager APIs to return error details +// for failed operations. (This also follows the OData error response format.). +type ErrorResponseCommonV2 struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// EventCategoryCollection a collection of event categories. Currently possible values are: Administrative, +// Security, ServiceHealth, Alert, Recommendation, Policy. +type EventCategoryCollection struct { + autorest.Response `json:"-"` + // Value - the list that includes the Azure event categories. + Value *[]LocalizableString `json:"value,omitempty"` +} + +// EventData the Azure event log entries are of type EventData +type EventData struct { + // Authorization - READ-ONLY; The sender authorization information. + Authorization *SenderAuthorization `json:"authorization,omitempty"` + // Claims - READ-ONLY; key value pairs to identify ARM permissions. + Claims map[string]*string `json:"claims"` + // Caller - READ-ONLY; the email address of the user who has performed the operation, the UPN claim or SPN claim based on availability. + Caller *string `json:"caller,omitempty"` + // Description - READ-ONLY; the description of the event. + Description *string `json:"description,omitempty"` + // ID - READ-ONLY; the Id of this event as required by ARM for RBAC. It contains the EventDataID and a timestamp information. + ID *string `json:"id,omitempty"` + // EventDataID - READ-ONLY; the event data Id. This is a unique identifier for an event. + EventDataID *string `json:"eventDataId,omitempty"` + // CorrelationID - READ-ONLY; the correlation Id, usually a GUID in the string format. The correlation Id is shared among the events that belong to the same uber operation. + CorrelationID *string `json:"correlationId,omitempty"` + // EventName - READ-ONLY; the event name. This value should not be confused with OperationName. For practical purposes, OperationName might be more appealing to end users. + EventName *LocalizableString `json:"eventName,omitempty"` + // Category - READ-ONLY; the event category. + Category *LocalizableString `json:"category,omitempty"` + // HTTPRequest - READ-ONLY; the HTTP request info. Usually includes the 'clientRequestId', 'clientIpAddress' (IP address of the user who initiated the event) and 'method' (HTTP method e.g. PUT). + HTTPRequest *HTTPRequestInfo `json:"httpRequest,omitempty"` + // Level - READ-ONLY; the event level. Possible values include: 'EventLevelCritical', 'EventLevelError', 'EventLevelWarning', 'EventLevelInformational', 'EventLevelVerbose' + Level EventLevel `json:"level,omitempty"` + // ResourceGroupName - READ-ONLY; the resource group name of the impacted resource. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // ResourceProviderName - READ-ONLY; the resource provider name of the impacted resource. + ResourceProviderName *LocalizableString `json:"resourceProviderName,omitempty"` + // ResourceID - READ-ONLY; the resource uri that uniquely identifies the resource that caused this event. + ResourceID *string `json:"resourceId,omitempty"` + // ResourceType - READ-ONLY; the resource type + ResourceType *LocalizableString `json:"resourceType,omitempty"` + // OperationID - READ-ONLY; It is usually a GUID shared among the events corresponding to single operation. This value should not be confused with EventName. + OperationID *string `json:"operationId,omitempty"` + // OperationName - READ-ONLY; the operation name. + OperationName *LocalizableString `json:"operationName,omitempty"` + // Properties - READ-ONLY; the set of pairs (usually a Dictionary) that includes details about the event. + Properties map[string]*string `json:"properties"` + // Status - READ-ONLY; a string describing the status of the operation. Some typical values are: Started, In progress, Succeeded, Failed, Resolved. + Status *LocalizableString `json:"status,omitempty"` + // SubStatus - READ-ONLY; the event sub status. Most of the time, when included, this captures the HTTP status code of the REST call. Common values are: OK (HTTP Status Code: 200), Created (HTTP Status Code: 201), Accepted (HTTP Status Code: 202), No Content (HTTP Status Code: 204), Bad Request(HTTP Status Code: 400), Not Found (HTTP Status Code: 404), Conflict (HTTP Status Code: 409), Internal Server Error (HTTP Status Code: 500), Service Unavailable (HTTP Status Code:503), Gateway Timeout (HTTP Status Code: 504) + SubStatus *LocalizableString `json:"subStatus,omitempty"` + // EventTimestamp - READ-ONLY; the timestamp of when the event was generated by the Azure service processing the request corresponding the event. It in ISO 8601 format. + EventTimestamp *date.Time `json:"eventTimestamp,omitempty"` + // SubmissionTimestamp - READ-ONLY; the timestamp of when the event became available for querying via this API. It is in ISO 8601 format. This value should not be confused eventTimestamp. As there might be a delay between the occurrence time of the event, and the time that the event is submitted to the Azure logging infrastructure. + SubmissionTimestamp *date.Time `json:"submissionTimestamp,omitempty"` + // SubscriptionID - READ-ONLY; the Azure subscription Id usually a GUID. + SubscriptionID *string `json:"subscriptionId,omitempty"` + // TenantID - READ-ONLY; the Azure tenant Id + TenantID *string `json:"tenantId,omitempty"` +} + +// MarshalJSON is the custom marshaler for EventData. +func (ed EventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// EventDataCollection represents collection of events. +type EventDataCollection struct { + autorest.Response `json:"-"` + // Value - this list that includes the Azure audit logs. + Value *[]EventData `json:"value,omitempty"` + // NextLink - Provides the link to retrieve the next set of events. + NextLink *string `json:"nextLink,omitempty"` +} + +// EventDataCollectionIterator provides access to a complete listing of EventData values. +type EventDataCollectionIterator struct { + i int + page EventDataCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *EventDataCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventDataCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *EventDataCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EventDataCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter EventDataCollectionIterator) Response() EventDataCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter EventDataCollectionIterator) Value() EventData { + if !iter.page.NotDone() { + return EventData{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EventDataCollectionIterator type. +func NewEventDataCollectionIterator(page EventDataCollectionPage) EventDataCollectionIterator { + return EventDataCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (edc EventDataCollection) IsEmpty() bool { + return edc.Value == nil || len(*edc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (edc EventDataCollection) hasNextLink() bool { + return edc.NextLink != nil && len(*edc.NextLink) != 0 +} + +// eventDataCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (edc EventDataCollection) eventDataCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !edc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(edc.NextLink))) +} + +// EventDataCollectionPage contains a page of EventData values. +type EventDataCollectionPage struct { + fn func(context.Context, EventDataCollection) (EventDataCollection, error) + edc EventDataCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *EventDataCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventDataCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.edc) + if err != nil { + return err + } + page.edc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *EventDataCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EventDataCollectionPage) NotDone() bool { + return !page.edc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EventDataCollectionPage) Response() EventDataCollection { + return page.edc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EventDataCollectionPage) Values() []EventData { + if page.edc.IsEmpty() { + return nil + } + return *page.edc.Value +} + +// Creates a new instance of the EventDataCollectionPage type. +func NewEventDataCollectionPage(cur EventDataCollection, getNextPage func(context.Context, EventDataCollection) (EventDataCollection, error)) EventDataCollectionPage { + return EventDataCollectionPage{ + fn: getNextPage, + edc: cur, + } +} + +// ExtensionDataSource definition of which data will be collected from a separate VM extension that +// integrates with the Azure Monitor Agent. +// Collected from either Windows and Linux machines, depending on which extension is defined. +type ExtensionDataSource struct { + // Streams - List of streams that this data source will be sent to. + // A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. + Streams *[]KnownExtensionDataSourceStreams `json:"streams,omitempty"` + // ExtensionName - The name of the VM extension. + ExtensionName *string `json:"extensionName,omitempty"` + // ExtensionSettings - The extension settings. The format is specific for particular extension. + ExtensionSettings interface{} `json:"extensionSettings,omitempty"` + // InputDataSources - The list of data sources this extension needs data from. + InputDataSources *[]string `json:"inputDataSources,omitempty"` + // Name - A friendly name for the data source. + // This name should be unique across all data sources (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// HTTPRequestInfo the Http request info. +type HTTPRequestInfo struct { + // ClientRequestID - the client request id. + ClientRequestID *string `json:"clientRequestId,omitempty"` + // ClientIPAddress - the client Ip Address + ClientIPAddress *string `json:"clientIpAddress,omitempty"` + // Method - the Http request method. + Method *string `json:"method,omitempty"` + // URI - the Uri. + URI *string `json:"uri,omitempty"` +} + +// Incident an alert incident indicates the activation status of an alert rule. +type Incident struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; Incident name. + Name *string `json:"name,omitempty"` + // RuleName - READ-ONLY; Rule name that is associated with the incident. + RuleName *string `json:"ruleName,omitempty"` + // IsActive - READ-ONLY; A boolean to indicate whether the incident is active or resolved. + IsActive *bool `json:"isActive,omitempty"` + // ActivatedTime - READ-ONLY; The time at which the incident was activated in ISO8601 format. + ActivatedTime *date.Time `json:"activatedTime,omitempty"` + // ResolvedTime - READ-ONLY; The time at which the incident was resolved in ISO8601 format. If null, it means the incident is still active. + ResolvedTime *date.Time `json:"resolvedTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for Incident. +func (i Incident) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// IncidentListResult the List incidents operation response. +type IncidentListResult struct { + autorest.Response `json:"-"` + // Value - the incident collection. + Value *[]Incident `json:"value,omitempty"` +} + +// ItsmReceiver an Itsm receiver. +type ItsmReceiver struct { + // Name - The name of the Itsm receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // WorkspaceID - OMS LA instance identifier. + WorkspaceID *string `json:"workspaceId,omitempty"` + // ConnectionID - Unique identification of ITSM connection among multiple defined in above workspace. + ConnectionID *string `json:"connectionId,omitempty"` + // TicketConfiguration - JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. + TicketConfiguration *string `json:"ticketConfiguration,omitempty"` + // Region - Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope' + Region *string `json:"region,omitempty"` +} + +// LocalizableString the localizable string class. +type LocalizableString struct { + // Value - the invariant value. + Value *string `json:"value,omitempty"` + // LocalizedValue - the locale specific value. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// LocationThresholdRuleCondition a rule condition based on a certain number of locations failing. +type LocationThresholdRuleCondition struct { + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + WindowSize *string `json:"windowSize,omitempty"` + // FailedLocationCount - the number of locations that must fail to activate the alert. + FailedLocationCount *int32 `json:"failedLocationCount,omitempty"` + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) MarshalJSON() ([]byte, error) { + ltrc.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition + objectMap := make(map[string]interface{}) + if ltrc.WindowSize != nil { + objectMap["windowSize"] = ltrc.WindowSize + } + if ltrc.FailedLocationCount != nil { + objectMap["failedLocationCount"] = ltrc.FailedLocationCount + } + objectMap["dataSource"] = ltrc.DataSource + if ltrc.OdataType != "" { + objectMap["odata.type"] = ltrc.OdataType + } + return json.Marshal(objectMap) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return nil, false +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return <rc, true +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return nil, false +} + +// AsRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return nil, false +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return <rc, true +} + +// UnmarshalJSON is the custom unmarshaler for LocationThresholdRuleCondition struct. +func (ltrc *LocationThresholdRuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "windowSize": + if v != nil { + var windowSize string + err = json.Unmarshal(*v, &windowSize) + if err != nil { + return err + } + ltrc.WindowSize = &windowSize + } + case "failedLocationCount": + if v != nil { + var failedLocationCount int32 + err = json.Unmarshal(*v, &failedLocationCount) + if err != nil { + return err + } + ltrc.FailedLocationCount = &failedLocationCount + } + case "dataSource": + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*v) + if err != nil { + return err + } + ltrc.DataSource = dataSource + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicRuleCondition + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + ltrc.OdataType = odataType + } + } + } + + return nil +} + +// LogAnalyticsDestination log Analytics destination. +type LogAnalyticsDestination struct { + // WorkspaceResourceID - The resource ID of the Log Analytics workspace. + WorkspaceResourceID *string `json:"workspaceResourceId,omitempty"` + // WorkspaceID - READ-ONLY; The Customer ID of the Log Analytics workspace. + WorkspaceID *string `json:"workspaceId,omitempty"` + // Name - A friendly name for the destination. + // This name should be unique across all destinations (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogAnalyticsDestination. +func (lad LogAnalyticsDestination) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lad.WorkspaceResourceID != nil { + objectMap["workspaceResourceId"] = lad.WorkspaceResourceID + } + if lad.Name != nil { + objectMap["name"] = lad.Name + } + return json.Marshal(objectMap) +} + +// LogicAppReceiver a logic app receiver. +type LogicAppReceiver struct { + // Name - The name of the logic app receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // ResourceID - The azure resource id of the logic app receiver. + ResourceID *string `json:"resourceId,omitempty"` + // CallbackURL - The callback url where http request sent to. + CallbackURL *string `json:"callbackUrl,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// LogMetricTrigger a log metrics trigger descriptor. +type LogMetricTrigger struct { + // ThresholdOperator - Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: 'ConditionalOperatorGreaterThanOrEqual', 'ConditionalOperatorLessThanOrEqual', 'ConditionalOperatorGreaterThan', 'ConditionalOperatorLessThan', 'ConditionalOperatorEqual' + ThresholdOperator ConditionalOperator `json:"thresholdOperator,omitempty"` + // Threshold - The threshold of the metric trigger. + Threshold *float64 `json:"threshold,omitempty"` + // MetricTriggerType - Metric Trigger Type - 'Consecutive' or 'Total'. Possible values include: 'MetricTriggerTypeConsecutive', 'MetricTriggerTypeTotal' + MetricTriggerType MetricTriggerType `json:"metricTriggerType,omitempty"` + // MetricColumn - Evaluation of metric on a particular column + MetricColumn *string `json:"metricColumn,omitempty"` +} + +// LogProfileCollection represents a collection of log profiles. +type LogProfileCollection struct { + autorest.Response `json:"-"` + // Value - the values of the log profiles. + Value *[]LogProfileResource `json:"value,omitempty"` +} + +// LogProfileProperties the log profile properties. +type LogProfileProperties struct { + // StorageAccountID - the resource id of the storage account to which you would like to send the Activity Log. + StorageAccountID *string `json:"storageAccountId,omitempty"` + // ServiceBusRuleID - The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. + ServiceBusRuleID *string `json:"serviceBusRuleId,omitempty"` + // Locations - List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. + Locations *[]string `json:"locations,omitempty"` + // Categories - the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.' + Categories *[]string `json:"categories,omitempty"` + // RetentionPolicy - the retention policy for the events in the log. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// LogProfileResource the log profile resource. +type LogProfileResource struct { + autorest.Response `json:"-"` + // LogProfileProperties - The log profile properties of the resource. + *LogProfileProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogProfileResource. +func (lpr LogProfileResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lpr.LogProfileProperties != nil { + objectMap["properties"] = lpr.LogProfileProperties + } + if lpr.Location != nil { + objectMap["location"] = lpr.Location + } + if lpr.Tags != nil { + objectMap["tags"] = lpr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogProfileResource struct. +func (lpr *LogProfileResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var logProfileProperties LogProfileProperties + err = json.Unmarshal(*v, &logProfileProperties) + if err != nil { + return err + } + lpr.LogProfileProperties = &logProfileProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + lpr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + lpr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + lpr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + lpr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + lpr.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + lpr.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + lpr.Etag = &etag + } + } + } + + return nil +} + +// LogProfileResourcePatch the log profile resource for patch operations. +type LogProfileResourcePatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // LogProfileProperties - The log profile properties for an update operation. + *LogProfileProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogProfileResourcePatch. +func (lprp LogProfileResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lprp.Tags != nil { + objectMap["tags"] = lprp.Tags + } + if lprp.LogProfileProperties != nil { + objectMap["properties"] = lprp.LogProfileProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogProfileResourcePatch struct. +func (lprp *LogProfileResourcePatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + lprp.Tags = tags + } + case "properties": + if v != nil { + var logProfileProperties LogProfileProperties + err = json.Unmarshal(*v, &logProfileProperties) + if err != nil { + return err + } + lprp.LogProfileProperties = &logProfileProperties + } + } + } + + return nil +} + +// LogSearchRule log Search Rule Definition +type LogSearchRule struct { + // CreatedWithAPIVersion - READ-ONLY; The api-version used when creating this alert rule + CreatedWithAPIVersion *string `json:"createdWithApiVersion,omitempty"` + // IsLegacyLogAnalyticsRule - READ-ONLY; True if alert rule is legacy Log Analytic rule + IsLegacyLogAnalyticsRule *bool `json:"isLegacyLogAnalyticsRule,omitempty"` + // Description - The description of the Log Search rule. + Description *string `json:"description,omitempty"` + // DisplayName - The display name of the alert rule + DisplayName *string `json:"displayName,omitempty"` + // AutoMitigate - The flag that indicates whether the alert should be automatically resolved or not. The default is false. + AutoMitigate *bool `json:"autoMitigate,omitempty"` + // Enabled - The flag which indicates whether the Log Search rule is enabled. Value should be true or false. Possible values include: 'True', 'False' + Enabled Enabled `json:"enabled,omitempty"` + // LastUpdatedTime - READ-ONLY; Last time the rule was updated in IS08601 format. + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the scheduled query rule. Possible values include: 'ProvisioningStateSucceeded', 'ProvisioningStateDeploying', 'ProvisioningStateCanceled', 'ProvisioningStateFailed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Source - Data Source against which rule will Query Data + Source *Source `json:"source,omitempty"` + // Schedule - Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction + Schedule *Schedule `json:"schedule,omitempty"` + // Action - Action needs to be taken on rule execution. + Action BasicAction `json:"action,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogSearchRule. +func (lsr LogSearchRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lsr.Description != nil { + objectMap["description"] = lsr.Description + } + if lsr.DisplayName != nil { + objectMap["displayName"] = lsr.DisplayName + } + if lsr.AutoMitigate != nil { + objectMap["autoMitigate"] = lsr.AutoMitigate + } + if lsr.Enabled != "" { + objectMap["enabled"] = lsr.Enabled + } + if lsr.Source != nil { + objectMap["source"] = lsr.Source + } + if lsr.Schedule != nil { + objectMap["schedule"] = lsr.Schedule + } + objectMap["action"] = lsr.Action + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogSearchRule struct. +func (lsr *LogSearchRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "createdWithApiVersion": + if v != nil { + var createdWithAPIVersion string + err = json.Unmarshal(*v, &createdWithAPIVersion) + if err != nil { + return err + } + lsr.CreatedWithAPIVersion = &createdWithAPIVersion + } + case "isLegacyLogAnalyticsRule": + if v != nil { + var isLegacyLogAnalyticsRule bool + err = json.Unmarshal(*v, &isLegacyLogAnalyticsRule) + if err != nil { + return err + } + lsr.IsLegacyLogAnalyticsRule = &isLegacyLogAnalyticsRule + } + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + lsr.Description = &description + } + case "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + lsr.DisplayName = &displayName + } + case "autoMitigate": + if v != nil { + var autoMitigate bool + err = json.Unmarshal(*v, &autoMitigate) + if err != nil { + return err + } + lsr.AutoMitigate = &autoMitigate + } + case "enabled": + if v != nil { + var enabled Enabled + err = json.Unmarshal(*v, &enabled) + if err != nil { + return err + } + lsr.Enabled = enabled + } + case "lastUpdatedTime": + if v != nil { + var lastUpdatedTime date.Time + err = json.Unmarshal(*v, &lastUpdatedTime) + if err != nil { + return err + } + lsr.LastUpdatedTime = &lastUpdatedTime + } + case "provisioningState": + if v != nil { + var provisioningState ProvisioningState + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + lsr.ProvisioningState = provisioningState + } + case "source": + if v != nil { + var source Source + err = json.Unmarshal(*v, &source) + if err != nil { + return err + } + lsr.Source = &source + } + case "schedule": + if v != nil { + var schedule Schedule + err = json.Unmarshal(*v, &schedule) + if err != nil { + return err + } + lsr.Schedule = &schedule + } + case "action": + if v != nil { + action, err := unmarshalBasicAction(*v) + if err != nil { + return err + } + lsr.Action = action + } + } + } + + return nil +} + +// LogSearchRulePatch log Search Rule Definition for Patching +type LogSearchRulePatch struct { + // Enabled - The flag which indicates whether the Log Search rule is enabled. Value should be true or false. Possible values include: 'True', 'False' + Enabled Enabled `json:"enabled,omitempty"` +} + +// LogSearchRuleResource the Log Search Rule resource. +type LogSearchRuleResource struct { + autorest.Response `json:"-"` + // LogSearchRule - The rule properties of the resource. + *LogSearchRule `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogSearchRuleResource. +func (lsrr LogSearchRuleResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lsrr.LogSearchRule != nil { + objectMap["properties"] = lsrr.LogSearchRule + } + if lsrr.Location != nil { + objectMap["location"] = lsrr.Location + } + if lsrr.Tags != nil { + objectMap["tags"] = lsrr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogSearchRuleResource struct. +func (lsrr *LogSearchRuleResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var logSearchRule LogSearchRule + err = json.Unmarshal(*v, &logSearchRule) + if err != nil { + return err + } + lsrr.LogSearchRule = &logSearchRule + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + lsrr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + lsrr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + lsrr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + lsrr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + lsrr.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + lsrr.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + lsrr.Etag = &etag + } + } + } + + return nil +} + +// LogSearchRuleResourceCollection represents a collection of Log Search rule resources. +type LogSearchRuleResourceCollection struct { + autorest.Response `json:"-"` + // Value - The values for the Log Search Rule resources. + Value *[]LogSearchRuleResource `json:"value,omitempty"` +} + +// LogSearchRuleResourcePatch the log search rule resource for patch operations. +type LogSearchRuleResourcePatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // LogSearchRulePatch - The log search rule properties of the resource. + *LogSearchRulePatch `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogSearchRuleResourcePatch. +func (lsrrp LogSearchRuleResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lsrrp.Tags != nil { + objectMap["tags"] = lsrrp.Tags + } + if lsrrp.LogSearchRulePatch != nil { + objectMap["properties"] = lsrrp.LogSearchRulePatch + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogSearchRuleResourcePatch struct. +func (lsrrp *LogSearchRuleResourcePatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + lsrrp.Tags = tags + } + case "properties": + if v != nil { + var logSearchRulePatch LogSearchRulePatch + err = json.Unmarshal(*v, &logSearchRulePatch) + if err != nil { + return err + } + lsrrp.LogSearchRulePatch = &logSearchRulePatch + } + } + } + + return nil +} + +// LogSettings part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. +type LogSettings struct { + // Category - Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. + Category *string `json:"category,omitempty"` + // Enabled - a value indicating whether this log is enabled. + Enabled *bool `json:"enabled,omitempty"` + // RetentionPolicy - the retention policy for this log. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// LogsIngestionEndpointSpec definition of the endpoint used for ingesting logs. +type LogsIngestionEndpointSpec struct { + // Endpoint - READ-ONLY; The endpoint. This property is READ-ONLY. + Endpoint *string `json:"endpoint,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogsIngestionEndpointSpec. +func (lies LogsIngestionEndpointSpec) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LogToMetricAction specify action need to be taken when rule type is converting log to metric +type LogToMetricAction struct { + // Criteria - Criteria of Metric + Criteria *[]Criteria `json:"criteria,omitempty"` + // OdataType - Possible values include: 'OdataTypeAction', 'OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction', 'OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction' + OdataType OdataTypeBasicAction `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogToMetricAction. +func (ltma LogToMetricAction) MarshalJSON() ([]byte, error) { + ltma.OdataType = OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction + objectMap := make(map[string]interface{}) + if ltma.Criteria != nil { + objectMap["criteria"] = ltma.Criteria + } + if ltma.OdataType != "" { + objectMap["odata.type"] = ltma.OdataType + } + return json.Marshal(objectMap) +} + +// AsAlertingAction is the BasicAction implementation for LogToMetricAction. +func (ltma LogToMetricAction) AsAlertingAction() (*AlertingAction, bool) { + return nil, false +} + +// AsLogToMetricAction is the BasicAction implementation for LogToMetricAction. +func (ltma LogToMetricAction) AsLogToMetricAction() (*LogToMetricAction, bool) { + return <ma, true +} + +// AsAction is the BasicAction implementation for LogToMetricAction. +func (ltma LogToMetricAction) AsAction() (*Action, bool) { + return nil, false +} + +// AsBasicAction is the BasicAction implementation for LogToMetricAction. +func (ltma LogToMetricAction) AsBasicAction() (BasicAction, bool) { + return <ma, true +} + +// ManagementEventAggregationCondition how the data that is collected should be combined over time. +type ManagementEventAggregationCondition struct { + // Operator - the condition operator. Possible values include: 'ConditionOperatorGreaterThan', 'ConditionOperatorGreaterThanOrEqual', 'ConditionOperatorLessThan', 'ConditionOperatorLessThanOrEqual' + Operator ConditionOperator `json:"operator,omitempty"` + // Threshold - The threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + WindowSize *string `json:"windowSize,omitempty"` +} + +// ManagementEventRuleCondition a management event rule condition. +type ManagementEventRuleCondition struct { + // Aggregation - How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate. + Aggregation *ManagementEventAggregationCondition `json:"aggregation,omitempty"` + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) MarshalJSON() ([]byte, error) { + merc.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition + objectMap := make(map[string]interface{}) + if merc.Aggregation != nil { + objectMap["aggregation"] = merc.Aggregation + } + objectMap["dataSource"] = merc.DataSource + if merc.OdataType != "" { + objectMap["odata.type"] = merc.OdataType + } + return json.Marshal(objectMap) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return nil, false +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return nil, false +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return &merc, true +} + +// AsRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return nil, false +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return &merc, true +} + +// UnmarshalJSON is the custom unmarshaler for ManagementEventRuleCondition struct. +func (merc *ManagementEventRuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "aggregation": + if v != nil { + var aggregation ManagementEventAggregationCondition + err = json.Unmarshal(*v, &aggregation) + if err != nil { + return err + } + merc.Aggregation = &aggregation + } + case "dataSource": + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*v) + if err != nil { + return err + } + merc.DataSource = dataSource + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicRuleCondition + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + merc.OdataType = odataType + } + } + } + + return nil +} + +// MetadataValue represents a metric metadata value. +type MetadataValue struct { + // Name - the name of the metadata. + Name *LocalizableString `json:"name,omitempty"` + // Value - the value of the metadata. + Value *string `json:"value,omitempty"` +} + +// Metric the result data of a query. +type Metric struct { + // ID - the metric Id. + ID *string `json:"id,omitempty"` + // Type - the resource type of the metric resource. + Type *string `json:"type,omitempty"` + // Name - the name and the display name of the metric, i.e. it is localizable string. + Name *LocalizableString `json:"name,omitempty"` + // DisplayDescription - Detailed description of this metric. + DisplayDescription *string `json:"displayDescription,omitempty"` + // ErrorCode - 'Success' or the error details on query failures for this metric. + ErrorCode *string `json:"errorCode,omitempty"` + // Unit - the unit of the metric. Possible values include: 'MetricUnitCount', 'MetricUnitBytes', 'MetricUnitSeconds', 'MetricUnitCountPerSecond', 'MetricUnitBytesPerSecond', 'MetricUnitPercent', 'MetricUnitMilliSeconds', 'MetricUnitByteSeconds', 'MetricUnitUnspecified', 'MetricUnitCores', 'MetricUnitMilliCores', 'MetricUnitNanoCores', 'MetricUnitBitsPerSecond' + Unit MetricUnit `json:"unit,omitempty"` + // Timeseries - the time series returned when a data query is performed. + Timeseries *[]TimeSeriesElement `json:"timeseries,omitempty"` +} + +// MetricAlertAction an alert action. +type MetricAlertAction struct { + // ActionGroupID - the id of the action group to use. + ActionGroupID *string `json:"actionGroupId,omitempty"` + // WebHookProperties - This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook. + WebHookProperties map[string]*string `json:"webHookProperties"` +} + +// MarshalJSON is the custom marshaler for MetricAlertAction. +func (maa MetricAlertAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if maa.ActionGroupID != nil { + objectMap["actionGroupId"] = maa.ActionGroupID + } + if maa.WebHookProperties != nil { + objectMap["webHookProperties"] = maa.WebHookProperties + } + return json.Marshal(objectMap) +} + +// BasicMetricAlertCriteria the rule criteria that defines the conditions of the alert rule. +type BasicMetricAlertCriteria interface { + AsMetricAlertSingleResourceMultipleMetricCriteria() (*MetricAlertSingleResourceMultipleMetricCriteria, bool) + AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) + AsMetricAlertMultipleResourceMultipleMetricCriteria() (*MetricAlertMultipleResourceMultipleMetricCriteria, bool) + AsMetricAlertCriteria() (*MetricAlertCriteria, bool) +} + +// MetricAlertCriteria the rule criteria that defines the conditions of the alert rule. +type MetricAlertCriteria struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria' + OdataType OdataTypeBasicMetricAlertCriteria `json:"odata.type,omitempty"` +} + +func unmarshalBasicMetricAlertCriteria(body []byte) (BasicMetricAlertCriteria, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria): + var masrmmc MetricAlertSingleResourceMultipleMetricCriteria + err := json.Unmarshal(body, &masrmmc) + return masrmmc, err + case string(OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria): + var wlac WebtestLocationAvailabilityCriteria + err := json.Unmarshal(body, &wlac) + return wlac, err + case string(OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria): + var mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria + err := json.Unmarshal(body, &mamrmmc) + return mamrmmc, err + default: + var mac MetricAlertCriteria + err := json.Unmarshal(body, &mac) + return mac, err + } +} +func unmarshalBasicMetricAlertCriteriaArray(body []byte) ([]BasicMetricAlertCriteria, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + macArray := make([]BasicMetricAlertCriteria, len(rawMessages)) + + for index, rawMessage := range rawMessages { + mac, err := unmarshalBasicMetricAlertCriteria(*rawMessage) + if err != nil { + return nil, err + } + macArray[index] = mac + } + return macArray, nil +} + +// MarshalJSON is the custom marshaler for MetricAlertCriteria. +func (mac MetricAlertCriteria) MarshalJSON() ([]byte, error) { + mac.OdataType = OdataTypeMetricAlertCriteria + objectMap := make(map[string]interface{}) + if mac.OdataType != "" { + objectMap["odata.type"] = mac.OdataType + } + for k, v := range mac.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricAlertSingleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertCriteria. +func (mac MetricAlertCriteria) AsMetricAlertSingleResourceMultipleMetricCriteria() (*MetricAlertSingleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsWebtestLocationAvailabilityCriteria is the BasicMetricAlertCriteria implementation for MetricAlertCriteria. +func (mac MetricAlertCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) { + return nil, false +} + +// AsMetricAlertMultipleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertCriteria. +func (mac MetricAlertCriteria) AsMetricAlertMultipleResourceMultipleMetricCriteria() (*MetricAlertMultipleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertCriteria. +func (mac MetricAlertCriteria) AsMetricAlertCriteria() (*MetricAlertCriteria, bool) { + return &mac, true +} + +// AsBasicMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertCriteria. +func (mac MetricAlertCriteria) AsBasicMetricAlertCriteria() (BasicMetricAlertCriteria, bool) { + return &mac, true +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertCriteria struct. +func (mac *MetricAlertCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mac.AdditionalProperties == nil { + mac.AdditionalProperties = make(map[string]interface{}) + } + mac.AdditionalProperties[k] = additionalProperties + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicMetricAlertCriteria + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + mac.OdataType = odataType + } + } + } + + return nil +} + +// MetricAlertMultipleResourceMultipleMetricCriteria specifies the metric alert criteria for multiple +// resource that has multiple metric criteria. +type MetricAlertMultipleResourceMultipleMetricCriteria struct { + // AllOf - the list of multiple metric criteria for this 'all of' operation. + AllOf *[]BasicMultiMetricCriteria `json:"allOf,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria' + OdataType OdataTypeBasicMetricAlertCriteria `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) { + mamrmmc.OdataType = OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria + objectMap := make(map[string]interface{}) + if mamrmmc.AllOf != nil { + objectMap["allOf"] = mamrmmc.AllOf + } + if mamrmmc.OdataType != "" { + objectMap["odata.type"] = mamrmmc.OdataType + } + for k, v := range mamrmmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricAlertSingleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) AsMetricAlertSingleResourceMultipleMetricCriteria() (*MetricAlertSingleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsWebtestLocationAvailabilityCriteria is the BasicMetricAlertCriteria implementation for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) { + return nil, false +} + +// AsMetricAlertMultipleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) AsMetricAlertMultipleResourceMultipleMetricCriteria() (*MetricAlertMultipleResourceMultipleMetricCriteria, bool) { + return &mamrmmc, true +} + +// AsMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) AsMetricAlertCriteria() (*MetricAlertCriteria, bool) { + return nil, false +} + +// AsBasicMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) AsBasicMetricAlertCriteria() (BasicMetricAlertCriteria, bool) { + return &mamrmmc, true +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertMultipleResourceMultipleMetricCriteria struct. +func (mamrmmc *MetricAlertMultipleResourceMultipleMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "allOf": + if v != nil { + allOf, err := unmarshalBasicMultiMetricCriteriaArray(*v) + if err != nil { + return err + } + mamrmmc.AllOf = &allOf + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mamrmmc.AdditionalProperties == nil { + mamrmmc.AdditionalProperties = make(map[string]interface{}) + } + mamrmmc.AdditionalProperties[k] = additionalProperties + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicMetricAlertCriteria + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + mamrmmc.OdataType = odataType + } + } + } + + return nil +} + +// MetricAlertProperties an alert rule. +type MetricAlertProperties struct { + // Description - the description of the metric alert that will be included in the alert email. + Description *string `json:"description,omitempty"` + // Severity - Alert severity {0, 1, 2, 3, 4} + Severity *int32 `json:"severity,omitempty"` + // Enabled - the flag that indicates whether the metric alert is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Scopes - the list of resource id's that this metric alert is scoped to. + Scopes *[]string `json:"scopes,omitempty"` + // EvaluationFrequency - how often the metric alert is evaluated represented in ISO 8601 duration format. + EvaluationFrequency *string `json:"evaluationFrequency,omitempty"` + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. + WindowSize *string `json:"windowSize,omitempty"` + // TargetResourceType - the resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. + TargetResourceType *string `json:"targetResourceType,omitempty"` + // TargetResourceRegion - the region of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. + TargetResourceRegion *string `json:"targetResourceRegion,omitempty"` + // Criteria - defines the specific alert criteria information. + Criteria BasicMetricAlertCriteria `json:"criteria,omitempty"` + // AutoMitigate - the flag that indicates whether the alert should be auto resolved or not. The default is true. + AutoMitigate *bool `json:"autoMitigate,omitempty"` + // Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + Actions *[]MetricAlertAction `json:"actions,omitempty"` + // LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format. + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` + // IsMigrated - READ-ONLY; the value indicating whether this alert rule is migrated. + IsMigrated *bool `json:"isMigrated,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertProperties. +func (mapVar MetricAlertProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mapVar.Description != nil { + objectMap["description"] = mapVar.Description + } + if mapVar.Severity != nil { + objectMap["severity"] = mapVar.Severity + } + if mapVar.Enabled != nil { + objectMap["enabled"] = mapVar.Enabled + } + if mapVar.Scopes != nil { + objectMap["scopes"] = mapVar.Scopes + } + if mapVar.EvaluationFrequency != nil { + objectMap["evaluationFrequency"] = mapVar.EvaluationFrequency + } + if mapVar.WindowSize != nil { + objectMap["windowSize"] = mapVar.WindowSize + } + if mapVar.TargetResourceType != nil { + objectMap["targetResourceType"] = mapVar.TargetResourceType + } + if mapVar.TargetResourceRegion != nil { + objectMap["targetResourceRegion"] = mapVar.TargetResourceRegion + } + objectMap["criteria"] = mapVar.Criteria + if mapVar.AutoMitigate != nil { + objectMap["autoMitigate"] = mapVar.AutoMitigate + } + if mapVar.Actions != nil { + objectMap["actions"] = mapVar.Actions + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertProperties struct. +func (mapVar *MetricAlertProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + mapVar.Description = &description + } + case "severity": + if v != nil { + var severity int32 + err = json.Unmarshal(*v, &severity) + if err != nil { + return err + } + mapVar.Severity = &severity + } + case "enabled": + if v != nil { + var enabled bool + err = json.Unmarshal(*v, &enabled) + if err != nil { + return err + } + mapVar.Enabled = &enabled + } + case "scopes": + if v != nil { + var scopes []string + err = json.Unmarshal(*v, &scopes) + if err != nil { + return err + } + mapVar.Scopes = &scopes + } + case "evaluationFrequency": + if v != nil { + var evaluationFrequency string + err = json.Unmarshal(*v, &evaluationFrequency) + if err != nil { + return err + } + mapVar.EvaluationFrequency = &evaluationFrequency + } + case "windowSize": + if v != nil { + var windowSize string + err = json.Unmarshal(*v, &windowSize) + if err != nil { + return err + } + mapVar.WindowSize = &windowSize + } + case "targetResourceType": + if v != nil { + var targetResourceType string + err = json.Unmarshal(*v, &targetResourceType) + if err != nil { + return err + } + mapVar.TargetResourceType = &targetResourceType + } + case "targetResourceRegion": + if v != nil { + var targetResourceRegion string + err = json.Unmarshal(*v, &targetResourceRegion) + if err != nil { + return err + } + mapVar.TargetResourceRegion = &targetResourceRegion + } + case "criteria": + if v != nil { + criteria, err := unmarshalBasicMetricAlertCriteria(*v) + if err != nil { + return err + } + mapVar.Criteria = criteria + } + case "autoMitigate": + if v != nil { + var autoMitigate bool + err = json.Unmarshal(*v, &autoMitigate) + if err != nil { + return err + } + mapVar.AutoMitigate = &autoMitigate + } + case "actions": + if v != nil { + var actions []MetricAlertAction + err = json.Unmarshal(*v, &actions) + if err != nil { + return err + } + mapVar.Actions = &actions + } + case "lastUpdatedTime": + if v != nil { + var lastUpdatedTime date.Time + err = json.Unmarshal(*v, &lastUpdatedTime) + if err != nil { + return err + } + mapVar.LastUpdatedTime = &lastUpdatedTime + } + case "isMigrated": + if v != nil { + var isMigrated bool + err = json.Unmarshal(*v, &isMigrated) + if err != nil { + return err + } + mapVar.IsMigrated = &isMigrated + } + } + } + + return nil +} + +// MetricAlertPropertiesPatch an alert rule properties for patch. +type MetricAlertPropertiesPatch struct { + // Description - the description of the metric alert that will be included in the alert email. + Description *string `json:"description,omitempty"` + // Severity - Alert severity {0, 1, 2, 3, 4} + Severity *int32 `json:"severity,omitempty"` + // Enabled - the flag that indicates whether the metric alert is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Scopes - the list of resource id's that this metric alert is scoped to. + Scopes *[]string `json:"scopes,omitempty"` + // EvaluationFrequency - how often the metric alert is evaluated represented in ISO 8601 duration format. + EvaluationFrequency *string `json:"evaluationFrequency,omitempty"` + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. + WindowSize *string `json:"windowSize,omitempty"` + // TargetResourceType - the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + TargetResourceType *string `json:"targetResourceType,omitempty"` + // TargetResourceRegion - the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + TargetResourceRegion *string `json:"targetResourceRegion,omitempty"` + // Criteria - defines the specific alert criteria information. + Criteria BasicMetricAlertCriteria `json:"criteria,omitempty"` + // AutoMitigate - the flag that indicates whether the alert should be auto resolved or not. The default is true. + AutoMitigate *bool `json:"autoMitigate,omitempty"` + // Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + Actions *[]MetricAlertAction `json:"actions,omitempty"` + // LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format. + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` + // IsMigrated - READ-ONLY; the value indicating whether this alert rule is migrated. + IsMigrated *bool `json:"isMigrated,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertPropertiesPatch. +func (mapp MetricAlertPropertiesPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mapp.Description != nil { + objectMap["description"] = mapp.Description + } + if mapp.Severity != nil { + objectMap["severity"] = mapp.Severity + } + if mapp.Enabled != nil { + objectMap["enabled"] = mapp.Enabled + } + if mapp.Scopes != nil { + objectMap["scopes"] = mapp.Scopes + } + if mapp.EvaluationFrequency != nil { + objectMap["evaluationFrequency"] = mapp.EvaluationFrequency + } + if mapp.WindowSize != nil { + objectMap["windowSize"] = mapp.WindowSize + } + if mapp.TargetResourceType != nil { + objectMap["targetResourceType"] = mapp.TargetResourceType + } + if mapp.TargetResourceRegion != nil { + objectMap["targetResourceRegion"] = mapp.TargetResourceRegion + } + objectMap["criteria"] = mapp.Criteria + if mapp.AutoMitigate != nil { + objectMap["autoMitigate"] = mapp.AutoMitigate + } + if mapp.Actions != nil { + objectMap["actions"] = mapp.Actions + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertPropertiesPatch struct. +func (mapp *MetricAlertPropertiesPatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + mapp.Description = &description + } + case "severity": + if v != nil { + var severity int32 + err = json.Unmarshal(*v, &severity) + if err != nil { + return err + } + mapp.Severity = &severity + } + case "enabled": + if v != nil { + var enabled bool + err = json.Unmarshal(*v, &enabled) + if err != nil { + return err + } + mapp.Enabled = &enabled + } + case "scopes": + if v != nil { + var scopes []string + err = json.Unmarshal(*v, &scopes) + if err != nil { + return err + } + mapp.Scopes = &scopes + } + case "evaluationFrequency": + if v != nil { + var evaluationFrequency string + err = json.Unmarshal(*v, &evaluationFrequency) + if err != nil { + return err + } + mapp.EvaluationFrequency = &evaluationFrequency + } + case "windowSize": + if v != nil { + var windowSize string + err = json.Unmarshal(*v, &windowSize) + if err != nil { + return err + } + mapp.WindowSize = &windowSize + } + case "targetResourceType": + if v != nil { + var targetResourceType string + err = json.Unmarshal(*v, &targetResourceType) + if err != nil { + return err + } + mapp.TargetResourceType = &targetResourceType + } + case "targetResourceRegion": + if v != nil { + var targetResourceRegion string + err = json.Unmarshal(*v, &targetResourceRegion) + if err != nil { + return err + } + mapp.TargetResourceRegion = &targetResourceRegion + } + case "criteria": + if v != nil { + criteria, err := unmarshalBasicMetricAlertCriteria(*v) + if err != nil { + return err + } + mapp.Criteria = criteria + } + case "autoMitigate": + if v != nil { + var autoMitigate bool + err = json.Unmarshal(*v, &autoMitigate) + if err != nil { + return err + } + mapp.AutoMitigate = &autoMitigate + } + case "actions": + if v != nil { + var actions []MetricAlertAction + err = json.Unmarshal(*v, &actions) + if err != nil { + return err + } + mapp.Actions = &actions + } + case "lastUpdatedTime": + if v != nil { + var lastUpdatedTime date.Time + err = json.Unmarshal(*v, &lastUpdatedTime) + if err != nil { + return err + } + mapp.LastUpdatedTime = &lastUpdatedTime + } + case "isMigrated": + if v != nil { + var isMigrated bool + err = json.Unmarshal(*v, &isMigrated) + if err != nil { + return err + } + mapp.IsMigrated = &isMigrated + } + } + } + + return nil +} + +// MetricAlertResource the metric alert resource. +type MetricAlertResource struct { + autorest.Response `json:"-"` + // MetricAlertProperties - The alert rule properties of the resource. + *MetricAlertProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertResource. +func (mar MetricAlertResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mar.MetricAlertProperties != nil { + objectMap["properties"] = mar.MetricAlertProperties + } + if mar.Location != nil { + objectMap["location"] = mar.Location + } + if mar.Tags != nil { + objectMap["tags"] = mar.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertResource struct. +func (mar *MetricAlertResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var metricAlertProperties MetricAlertProperties + err = json.Unmarshal(*v, &metricAlertProperties) + if err != nil { + return err + } + mar.MetricAlertProperties = &metricAlertProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mar.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mar.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mar.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + mar.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + mar.Etag = &etag + } + } + } + + return nil +} + +// MetricAlertResourceCollection represents a collection of alert rule resources. +type MetricAlertResourceCollection struct { + autorest.Response `json:"-"` + // Value - the values for the alert rule resources. + Value *[]MetricAlertResource `json:"value,omitempty"` +} + +// MetricAlertResourcePatch the metric alert resource for patch operations. +type MetricAlertResourcePatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // MetricAlertPropertiesPatch - The alert rule properties of the resource. + *MetricAlertPropertiesPatch `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertResourcePatch. +func (marp MetricAlertResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if marp.Tags != nil { + objectMap["tags"] = marp.Tags + } + if marp.MetricAlertPropertiesPatch != nil { + objectMap["properties"] = marp.MetricAlertPropertiesPatch + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertResourcePatch struct. +func (marp *MetricAlertResourcePatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + marp.Tags = tags + } + case "properties": + if v != nil { + var metricAlertPropertiesPatch MetricAlertPropertiesPatch + err = json.Unmarshal(*v, &metricAlertPropertiesPatch) + if err != nil { + return err + } + marp.MetricAlertPropertiesPatch = &metricAlertPropertiesPatch + } + } + } + + return nil +} + +// MetricAlertSingleResourceMultipleMetricCriteria specifies the metric alert criteria for a single +// resource that has multiple metric criteria. +type MetricAlertSingleResourceMultipleMetricCriteria struct { + // AllOf - The list of metric criteria for this 'all of' operation. + AllOf *[]MetricCriteria `json:"allOf,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria' + OdataType OdataTypeBasicMetricAlertCriteria `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) { + masrmmc.OdataType = OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria + objectMap := make(map[string]interface{}) + if masrmmc.AllOf != nil { + objectMap["allOf"] = masrmmc.AllOf + } + if masrmmc.OdataType != "" { + objectMap["odata.type"] = masrmmc.OdataType + } + for k, v := range masrmmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricAlertSingleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) AsMetricAlertSingleResourceMultipleMetricCriteria() (*MetricAlertSingleResourceMultipleMetricCriteria, bool) { + return &masrmmc, true +} + +// AsWebtestLocationAvailabilityCriteria is the BasicMetricAlertCriteria implementation for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) { + return nil, false +} + +// AsMetricAlertMultipleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) AsMetricAlertMultipleResourceMultipleMetricCriteria() (*MetricAlertMultipleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) AsMetricAlertCriteria() (*MetricAlertCriteria, bool) { + return nil, false +} + +// AsBasicMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) AsBasicMetricAlertCriteria() (BasicMetricAlertCriteria, bool) { + return &masrmmc, true +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertSingleResourceMultipleMetricCriteria struct. +func (masrmmc *MetricAlertSingleResourceMultipleMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "allOf": + if v != nil { + var allOf []MetricCriteria + err = json.Unmarshal(*v, &allOf) + if err != nil { + return err + } + masrmmc.AllOf = &allOf + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if masrmmc.AdditionalProperties == nil { + masrmmc.AdditionalProperties = make(map[string]interface{}) + } + masrmmc.AdditionalProperties[k] = additionalProperties + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicMetricAlertCriteria + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + masrmmc.OdataType = odataType + } + } + } + + return nil +} + +// MetricAlertStatus an alert status. +type MetricAlertStatus struct { + // Name - The status name. + Name *string `json:"name,omitempty"` + // ID - The alert rule arm id. + ID *string `json:"id,omitempty"` + // Type - The extended resource type name. + Type *string `json:"type,omitempty"` + // Properties - The alert status properties of the metric alert status. + Properties *MetricAlertStatusProperties `json:"properties,omitempty"` +} + +// MetricAlertStatusCollection represents a collection of alert rule resources. +type MetricAlertStatusCollection struct { + autorest.Response `json:"-"` + // Value - the values for the alert rule resources. + Value *[]MetricAlertStatus `json:"value,omitempty"` +} + +// MetricAlertStatusProperties an alert status properties. +type MetricAlertStatusProperties struct { + // Dimensions - An object describing the type of the dimensions. + Dimensions map[string]*string `json:"dimensions"` + // Status - status value + Status *string `json:"status,omitempty"` + // Timestamp - UTC time when the status was checked. + Timestamp *date.Time `json:"timestamp,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertStatusProperties. +func (masp MetricAlertStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if masp.Dimensions != nil { + objectMap["dimensions"] = masp.Dimensions + } + if masp.Status != nil { + objectMap["status"] = masp.Status + } + if masp.Timestamp != nil { + objectMap["timestamp"] = masp.Timestamp + } + return json.Marshal(objectMap) +} + +// MetricAvailability metric availability specifies the time grain (aggregation interval or frequency) and +// the retention period for that time grain. +type MetricAvailability struct { + // TimeGrain - the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. + TimeGrain *string `json:"timeGrain,omitempty"` + // Retention - the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. + Retention *string `json:"retention,omitempty"` +} + +// MetricBaselinesProperties the response to a metric baselines query. +type MetricBaselinesProperties struct { + // Timespan - The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + Timespan *string `json:"timespan,omitempty"` + // Interval - The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + Interval *string `json:"interval,omitempty"` + // Namespace - The namespace of the metrics been queried. + Namespace *string `json:"namespace,omitempty"` + // Baselines - The baseline for each time series that was queried. + Baselines *[]TimeSeriesBaseline `json:"baselines,omitempty"` +} + +// MetricBaselinesResponse a list of metric baselines. +type MetricBaselinesResponse struct { + autorest.Response `json:"-"` + // Value - The list of metric baselines. + Value *[]SingleMetricBaseline `json:"value,omitempty"` +} + +// MetricCriteria criterion to filter metrics. +type MetricCriteria struct { + // Operator - the criteria operator. Possible values include: 'OperatorEquals', 'OperatorNotEquals', 'OperatorGreaterThan', 'OperatorGreaterThanOrEqual', 'OperatorLessThan', 'OperatorLessThanOrEqual' + Operator Operator `json:"operator,omitempty"` + // Threshold - the criteria threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal' + TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. + SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' + CriterionType CriterionType `json:"criterionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricCriteria. +func (mc MetricCriteria) MarshalJSON() ([]byte, error) { + mc.CriterionType = CriterionTypeStaticThresholdCriterion + objectMap := make(map[string]interface{}) + if mc.Operator != "" { + objectMap["operator"] = mc.Operator + } + if mc.Threshold != nil { + objectMap["threshold"] = mc.Threshold + } + if mc.Name != nil { + objectMap["name"] = mc.Name + } + if mc.MetricName != nil { + objectMap["metricName"] = mc.MetricName + } + if mc.MetricNamespace != nil { + objectMap["metricNamespace"] = mc.MetricNamespace + } + if mc.TimeAggregation != "" { + objectMap["timeAggregation"] = mc.TimeAggregation + } + if mc.Dimensions != nil { + objectMap["dimensions"] = mc.Dimensions + } + if mc.SkipMetricValidation != nil { + objectMap["skipMetricValidation"] = mc.SkipMetricValidation + } + if mc.CriterionType != "" { + objectMap["criterionType"] = mc.CriterionType + } + for k, v := range mc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { + return &mc, true +} + +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + +// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { + return nil, false +} + +// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) { + return &mc, true +} + +// UnmarshalJSON is the custom unmarshaler for MetricCriteria struct. +func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "operator": + if v != nil { + var operator Operator + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + mc.Operator = operator + } + case "threshold": + if v != nil { + var threshold float64 + err = json.Unmarshal(*v, &threshold) + if err != nil { + return err + } + mc.Threshold = &threshold + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mc.AdditionalProperties == nil { + mc.AdditionalProperties = make(map[string]interface{}) + } + mc.AdditionalProperties[k] = additionalProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + mc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + mc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation AggregationTypeEnum + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + mc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + mc.Dimensions = &dimensions + } + case "skipMetricValidation": + if v != nil { + var skipMetricValidation bool + err = json.Unmarshal(*v, &skipMetricValidation) + if err != nil { + return err + } + mc.SkipMetricValidation = &skipMetricValidation + } + case "criterionType": + if v != nil { + var criterionType CriterionType + err = json.Unmarshal(*v, &criterionType) + if err != nil { + return err + } + mc.CriterionType = criterionType + } + } + } + + return nil +} + +// MetricDefinition metric definition class specifies the metadata for a metric. +type MetricDefinition struct { + // IsDimensionRequired - Flag to indicate whether the dimension is required. + IsDimensionRequired *bool `json:"isDimensionRequired,omitempty"` + // ResourceID - the resource identifier of the resource that emitted the metric. + ResourceID *string `json:"resourceId,omitempty"` + // Namespace - the namespace the metric belongs to. + Namespace *string `json:"namespace,omitempty"` + // Name - the name and the display name of the metric, i.e. it is a localizable string. + Name *LocalizableString `json:"name,omitempty"` + // DisplayDescription - Detailed description of this metric. + DisplayDescription *string `json:"displayDescription,omitempty"` + // Category - Custom category name for this metric. + Category *string `json:"category,omitempty"` + // Unit - the unit of the metric. Possible values include: 'MetricUnitCount', 'MetricUnitBytes', 'MetricUnitSeconds', 'MetricUnitCountPerSecond', 'MetricUnitBytesPerSecond', 'MetricUnitPercent', 'MetricUnitMilliSeconds', 'MetricUnitByteSeconds', 'MetricUnitUnspecified', 'MetricUnitCores', 'MetricUnitMilliCores', 'MetricUnitNanoCores', 'MetricUnitBitsPerSecond' + Unit MetricUnit `json:"unit,omitempty"` + // PrimaryAggregationType - the primary aggregation type value defining how to use the values for display. Possible values include: 'None', 'Average', 'Count', 'Minimum', 'Maximum', 'Total' + PrimaryAggregationType AggregationType `json:"primaryAggregationType,omitempty"` + // SupportedAggregationTypes - the collection of what aggregation types are supported. + SupportedAggregationTypes *[]AggregationType `json:"supportedAggregationTypes,omitempty"` + // MetricAvailabilities - the collection of what aggregation intervals are available to be queried. + MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` + // ID - the resource identifier of the metric definition. + ID *string `json:"id,omitempty"` + // Dimensions - the name and the display name of the dimension, i.e. it is a localizable string. + Dimensions *[]LocalizableString `json:"dimensions,omitempty"` +} + +// MetricDefinitionCollection represents collection of metric definitions. +type MetricDefinitionCollection struct { + autorest.Response `json:"-"` + // Value - the values for the metric definitions. + Value *[]MetricDefinition `json:"value,omitempty"` +} + +// MetricDimension specifies a metric dimension. +type MetricDimension struct { + // Name - Name of the dimension. + Name *string `json:"name,omitempty"` + // Operator - the dimension operator. Only 'Include' and 'Exclude' are supported + Operator *string `json:"operator,omitempty"` + // Values - list of dimension values. + Values *[]string `json:"values,omitempty"` +} + +// MetricNamespace metric namespace class specifies the metadata for a metric namespace. +type MetricNamespace struct { + // ID - The ID of the metric namespace. + ID *string `json:"id,omitempty"` + // Type - The type of the namespace. + Type *string `json:"type,omitempty"` + // Name - The escaped name of the namespace. + Name *string `json:"name,omitempty"` + // Classification - Kind of namespace. Possible values include: 'Platform', 'Custom', 'Qos' + Classification NamespaceClassification `json:"classification,omitempty"` + // Properties - Properties which include the fully qualified namespace name. + Properties *MetricNamespaceName `json:"properties,omitempty"` +} + +// MetricNamespaceCollection represents collection of metric namespaces. +type MetricNamespaceCollection struct { + autorest.Response `json:"-"` + // Value - The values for the metric namespaces. + Value *[]MetricNamespace `json:"value,omitempty"` +} + +// MetricNamespaceName the fully qualified metric namespace name. +type MetricNamespaceName struct { + // MetricNamespaceName - The metric namespace name. + MetricNamespaceName *string `json:"metricNamespaceName,omitempty"` +} + +// MetricSettings part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. +type MetricSettings struct { + // TimeGrain - the timegrain of the metric in ISO8601 format. + TimeGrain *string `json:"timeGrain,omitempty"` + // Category - Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. + Category *string `json:"category,omitempty"` + // Enabled - a value indicating whether this category is enabled. + Enabled *bool `json:"enabled,omitempty"` + // RetentionPolicy - the retention policy for this category. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// MetricSingleDimension the metric dimension name and value. +type MetricSingleDimension struct { + // Name - Name of the dimension. + Name *string `json:"name,omitempty"` + // Value - Value of the dimension. + Value *string `json:"value,omitempty"` +} + +// MetricTrigger the trigger that results in a scaling action. +type MetricTrigger struct { + // MetricName - the name of the metric that defines what the rule monitors. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - the namespace of the metric that defines what the rule monitors. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // MetricResourceURI - the resource identifier of the resource the rule monitors. + MetricResourceURI *string `json:"metricResourceUri,omitempty"` + // TimeGrain - the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. + TimeGrain *string `json:"timeGrain,omitempty"` + // Statistic - the metric statistic type. How the metrics from multiple instances are combined. Possible values include: 'MetricStatisticTypeAverage', 'MetricStatisticTypeMin', 'MetricStatisticTypeMax', 'MetricStatisticTypeSum' + Statistic MetricStatisticType `json:"statistic,omitempty"` + // TimeWindow - the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. + TimeWindow *string `json:"timeWindow,omitempty"` + // TimeAggregation - time aggregation type. How the data that is collected should be combined over time. The default value is Average. Possible values include: 'TimeAggregationTypeAverage', 'TimeAggregationTypeMinimum', 'TimeAggregationTypeMaximum', 'TimeAggregationTypeTotal', 'TimeAggregationTypeCount', 'TimeAggregationTypeLast' + TimeAggregation TimeAggregationType `json:"timeAggregation,omitempty"` + // Operator - the operator that is used to compare the metric data and the threshold. Possible values include: 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' + Operator ComparisonOperationType `json:"operator,omitempty"` + // Threshold - the threshold of the metric that triggers the scale action. + Threshold *float64 `json:"threshold,omitempty"` + // Dimensions - List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. + Dimensions *[]ScaleRuleMetricDimension `json:"dimensions,omitempty"` + // DividePerInstance - a value indicating whether metric should divide per instance. + DividePerInstance *bool `json:"dividePerInstance,omitempty"` +} + +// MetricValue represents a metric value. +type MetricValue struct { + // TimeStamp - the timestamp for the metric value in ISO 8601 format. + TimeStamp *date.Time `json:"timeStamp,omitempty"` + // Average - the average value in the time range. + Average *float64 `json:"average,omitempty"` + // Minimum - the least value in the time range. + Minimum *float64 `json:"minimum,omitempty"` + // Maximum - the greatest value in the time range. + Maximum *float64 `json:"maximum,omitempty"` + // Total - the sum of all of the values in the time range. + Total *float64 `json:"total,omitempty"` + // Count - the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. + Count *float64 `json:"count,omitempty"` +} + +// BasicMultiMetricCriteria the types of conditions for a multi resource alert. +type BasicMultiMetricCriteria interface { + AsMetricCriteria() (*MetricCriteria, bool) + AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) + AsMultiMetricCriteria() (*MultiMetricCriteria, bool) +} + +// MultiMetricCriteria the types of conditions for a multi resource alert. +type MultiMetricCriteria struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal' + TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. + SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' + CriterionType CriterionType `json:"criterionType,omitempty"` +} + +func unmarshalBasicMultiMetricCriteria(body []byte) (BasicMultiMetricCriteria, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["criterionType"] { + case string(CriterionTypeStaticThresholdCriterion): + var mc MetricCriteria + err := json.Unmarshal(body, &mc) + return mc, err + case string(CriterionTypeDynamicThresholdCriterion): + var dmc DynamicMetricCriteria + err := json.Unmarshal(body, &dmc) + return dmc, err + default: + var mmc MultiMetricCriteria + err := json.Unmarshal(body, &mmc) + return mmc, err + } +} +func unmarshalBasicMultiMetricCriteriaArray(body []byte) ([]BasicMultiMetricCriteria, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + mmcArray := make([]BasicMultiMetricCriteria, len(rawMessages)) + + for index, rawMessage := range rawMessages { + mmc, err := unmarshalBasicMultiMetricCriteria(*rawMessage) + if err != nil { + return nil, err + } + mmcArray[index] = mmc + } + return mmcArray, nil +} + +// MarshalJSON is the custom marshaler for MultiMetricCriteria. +func (mmc MultiMetricCriteria) MarshalJSON() ([]byte, error) { + mmc.CriterionType = CriterionTypeMultiMetricCriteria + objectMap := make(map[string]interface{}) + if mmc.Name != nil { + objectMap["name"] = mmc.Name + } + if mmc.MetricName != nil { + objectMap["metricName"] = mmc.MetricName + } + if mmc.MetricNamespace != nil { + objectMap["metricNamespace"] = mmc.MetricNamespace + } + if mmc.TimeAggregation != "" { + objectMap["timeAggregation"] = mmc.TimeAggregation + } + if mmc.Dimensions != nil { + objectMap["dimensions"] = mmc.Dimensions + } + if mmc.SkipMetricValidation != nil { + objectMap["skipMetricValidation"] = mmc.SkipMetricValidation + } + if mmc.CriterionType != "" { + objectMap["criterionType"] = mmc.CriterionType + } + for k, v := range mmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { + return nil, false +} + +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + +// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { + return &mmc, true +} + +// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) { + return &mmc, true +} + +// UnmarshalJSON is the custom unmarshaler for MultiMetricCriteria struct. +func (mmc *MultiMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mmc.AdditionalProperties == nil { + mmc.AdditionalProperties = make(map[string]interface{}) + } + mmc.AdditionalProperties[k] = additionalProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + mmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + mmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation AggregationTypeEnum + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + mmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + mmc.Dimensions = &dimensions + } + case "skipMetricValidation": + if v != nil { + var skipMetricValidation bool + err = json.Unmarshal(*v, &skipMetricValidation) + if err != nil { + return err + } + mmc.SkipMetricValidation = &skipMetricValidation + } + case "criterionType": + if v != nil { + var criterionType CriterionType + err = json.Unmarshal(*v, &criterionType) + if err != nil { + return err + } + mmc.CriterionType = criterionType + } + } + } + + return nil +} + +// NetworkRuleSet definition of the network rules. +type NetworkRuleSet struct { + // PublicNetworkAccess - The configuration to set whether network access from public internet to the endpoints are allowed. Possible values include: 'KnownPublicNetworkAccessOptionsEnabled', 'KnownPublicNetworkAccessOptionsDisabled' + PublicNetworkAccess KnownPublicNetworkAccessOptions `json:"publicNetworkAccess,omitempty"` +} + +// Operation microsoft Insights API operation definition. +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - Display metadata associated with the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.Insights + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: AlertRules, Autoscale, etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult result of the request to list Microsoft.Insights operations. It contains a list of +// operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the Microsoft.Insights provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationStatus the status of operation. +type OperationStatus struct { + autorest.Response `json:"-"` + // ID - The operation Id. + ID *string `json:"id,omitempty"` + // Name - The operation name. + Name *string `json:"name,omitempty"` + // StartTime - Start time of the job in standard ISO8601 format. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - End time of the job in standard ISO8601 format. + EndTime *date.Time `json:"endTime,omitempty"` + // Status - The status of the operation. + Status *string `json:"status,omitempty"` + // Error - The error detail of the operation if any. + Error *ErrorResponseCommon `json:"error,omitempty"` +} + +// PerfCounterDataSource definition of which performance counters will be collected and how they will be +// collected by this data collection rule. +// Collected from both Windows and Linux machines where the counter is present. +type PerfCounterDataSource struct { + // Streams - List of streams that this data source will be sent to. + // A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. + Streams *[]KnownPerfCounterDataSourceStreams `json:"streams,omitempty"` + // SamplingFrequencyInSeconds - The number of seconds between consecutive counter measurements (samples). + SamplingFrequencyInSeconds *int32 `json:"samplingFrequencyInSeconds,omitempty"` + // CounterSpecifiers - A list of specifier names of the performance counters you want to collect. + // Use a wildcard (*) to collect a counter for all instances. + // To get a list of performance counters on Windows, run the command 'typeperf'. + CounterSpecifiers *[]string `json:"counterSpecifiers,omitempty"` + // Name - A friendly name for the data source. + // This name should be unique across all data sources (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// PrivateEndpointConnection a private endpoint connection +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // PrivateEndpointConnectionProperties - Resource properties. + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionListResult a list of private endpoint connections. +type PrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]PrivateEndpointConnection `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionListResult. +func (peclr PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionListResultIterator provides access to a complete listing of +// PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultIterator struct { + i int + page PrivateEndpointConnectionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateEndpointConnectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateEndpointConnectionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateEndpointConnectionListResultIterator) Response() PrivateEndpointConnectionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateEndpointConnectionListResultIterator) Value() PrivateEndpointConnection { + if !iter.page.NotDone() { + return PrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateEndpointConnectionListResultIterator type. +func NewPrivateEndpointConnectionListResultIterator(page PrivateEndpointConnectionListResultPage) PrivateEndpointConnectionListResultIterator { + return PrivateEndpointConnectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (peclr PrivateEndpointConnectionListResult) IsEmpty() bool { + return peclr.Value == nil || len(*peclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (peclr PrivateEndpointConnectionListResult) hasNextLink() bool { + return peclr.NextLink != nil && len(*peclr.NextLink) != 0 +} + +// privateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (peclr PrivateEndpointConnectionListResult) privateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !peclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(peclr.NextLink))) +} + +// PrivateEndpointConnectionListResultPage contains a page of PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultPage struct { + fn func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error) + peclr PrivateEndpointConnectionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.peclr) + if err != nil { + return err + } + page.peclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateEndpointConnectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateEndpointConnectionListResultPage) NotDone() bool { + return !page.peclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateEndpointConnectionListResultPage) Response() PrivateEndpointConnectionListResult { + return page.peclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateEndpointConnectionListResultPage) Values() []PrivateEndpointConnection { + if page.peclr.IsEmpty() { + return nil + } + return *page.peclr.Value +} + +// Creates a new instance of the PrivateEndpointConnectionListResultPage type. +func NewPrivateEndpointConnectionListResultPage(cur PrivateEndpointConnectionListResult, getNextPage func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error)) PrivateEndpointConnectionListResultPage { + return PrivateEndpointConnectionListResultPage{ + fn: getNextPage, + peclr: cur, + } +} + +// PrivateEndpointConnectionProperties properties of a private endpoint connection. +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - Private endpoint which the connection belongs to. + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection state of the private endpoint connection. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + // ProvisioningState - READ-ONLY; State of the private endpoint connection. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionProperties. +func (pecp PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = pecp.PrivateEndpoint + } + if pecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = pecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) result(client PrivateEndpointConnectionsClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("insights.PrivateEndpointConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsDeleteFuture.Result. +func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("insights.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointProperty private endpoint which the connection belongs to. +type PrivateEndpointProperty struct { + // ID - Resource id of the private endpoint. + ID *string `json:"id,omitempty"` +} + +// PrivateLinkResource a private link resource +type PrivateLinkResource struct { + autorest.Response `json:"-"` + // PrivateLinkResourceProperties - Resource properties. + *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plr.PrivateLinkResourceProperties != nil { + objectMap["properties"] = plr.PrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. +func (plr *PrivateLinkResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plr.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + plr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + plr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + plr.Type = &typeVar + } + } + } + + return nil +} + +// PrivateLinkResourceListResult a list of private link resources +type PrivateLinkResourceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]PrivateLinkResource `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceListResult. +func (plrlr PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceListResultIterator provides access to a complete listing of PrivateLinkResource +// values. +type PrivateLinkResourceListResultIterator struct { + i int + page PrivateLinkResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkResourceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkResourceListResultIterator) Response() PrivateLinkResourceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkResourceListResultIterator) Value() PrivateLinkResource { + if !iter.page.NotDone() { + return PrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkResourceListResultIterator type. +func NewPrivateLinkResourceListResultIterator(page PrivateLinkResourceListResultPage) PrivateLinkResourceListResultIterator { + return PrivateLinkResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plrlr PrivateLinkResourceListResult) IsEmpty() bool { + return plrlr.Value == nil || len(*plrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plrlr PrivateLinkResourceListResult) hasNextLink() bool { + return plrlr.NextLink != nil && len(*plrlr.NextLink) != 0 +} + +// privateLinkResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plrlr PrivateLinkResourceListResult) privateLinkResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !plrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plrlr.NextLink))) +} + +// PrivateLinkResourceListResultPage contains a page of PrivateLinkResource values. +type PrivateLinkResourceListResultPage struct { + fn func(context.Context, PrivateLinkResourceListResult) (PrivateLinkResourceListResult, error) + plrlr PrivateLinkResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plrlr) + if err != nil { + return err + } + page.plrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkResourceListResultPage) NotDone() bool { + return !page.plrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkResourceListResultPage) Response() PrivateLinkResourceListResult { + return page.plrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkResourceListResultPage) Values() []PrivateLinkResource { + if page.plrlr.IsEmpty() { + return nil + } + return *page.plrlr.Value +} + +// Creates a new instance of the PrivateLinkResourceListResultPage type. +func NewPrivateLinkResourceListResultPage(cur PrivateLinkResourceListResult, getNextPage func(context.Context, PrivateLinkResourceListResult) (PrivateLinkResourceListResult, error)) PrivateLinkResourceListResultPage { + return PrivateLinkResourceListResultPage{ + fn: getNextPage, + plrlr: cur, + } +} + +// PrivateLinkResourceProperties properties of a private link resource. +type PrivateLinkResourceProperties struct { + // GroupID - READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The private link resource required member names. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceProperties. +func (plrp PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateLinkScopedResourcesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateLinkScopedResourcesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkScopedResourcesClient) (ScopedResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkScopedResourcesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkScopedResourcesCreateOrUpdateFuture.Result. +func (future *PrivateLinkScopedResourcesCreateOrUpdateFuture) result(client PrivateLinkScopedResourcesClient) (sr ScopedResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("insights.PrivateLinkScopedResourcesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sr.Response.Response, err = future.GetResult(sender); err == nil && sr.Response.Response.StatusCode != http.StatusNoContent { + sr, err = client.CreateOrUpdateResponder(sr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesCreateOrUpdateFuture", "Result", sr.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkScopedResourcesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateLinkScopedResourcesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkScopedResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkScopedResourcesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkScopedResourcesDeleteFuture.Result. +func (future *PrivateLinkScopedResourcesDeleteFuture) result(client PrivateLinkScopedResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("insights.PrivateLinkScopedResourcesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkScopesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PrivateLinkScopesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkScopesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkScopesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkScopesDeleteFuture.Result. +func (future *PrivateLinkScopesDeleteFuture) result(client PrivateLinkScopesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("insights.PrivateLinkScopesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkScopesResource an azure resource object +type PrivateLinkScopesResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkScopesResource. +func (plsr PrivateLinkScopesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsr.Location != nil { + objectMap["location"] = plsr.Location + } + if plsr.Tags != nil { + objectMap["tags"] = plsr.Tags + } + return json.Marshal(objectMap) +} + +// PrivateLinkServiceConnectionStateProperty state of the private endpoint connection. +type PrivateLinkServiceConnectionStateProperty struct { + // Status - The private link service connection status. + Status *string `json:"status,omitempty"` + // Description - The private link service connection description. + Description *string `json:"description,omitempty"` + // ActionsRequired - READ-ONLY; The actions required for private link service connection. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServiceConnectionStateProperty. +func (plscsp PrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plscsp.Status != nil { + objectMap["status"] = plscsp.Status + } + if plscsp.Description != nil { + objectMap["description"] = plscsp.Description + } + return json.Marshal(objectMap) +} + +// ProxyOnlyResource a proxy only azure resource object +type ProxyOnlyResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyOnlyResource. +func (por ProxyOnlyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ProxyResource an azure resource object +type ProxyResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Recurrence the repeating times at which this profile begins. This element is not used if the FixedDate +// element is used. +type Recurrence struct { + // Frequency - the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the schedule is repeated weekly. Possible values include: 'RecurrenceFrequencyNone', 'RecurrenceFrequencySecond', 'RecurrenceFrequencyMinute', 'RecurrenceFrequencyHour', 'RecurrenceFrequencyDay', 'RecurrenceFrequencyWeek', 'RecurrenceFrequencyMonth', 'RecurrenceFrequencyYear' + Frequency RecurrenceFrequency `json:"frequency,omitempty"` + // Schedule - the scheduling constraints for when the profile begins. + Schedule *RecurrentSchedule `json:"schedule,omitempty"` +} + +// RecurrentSchedule the scheduling constraints for when the profile begins. +type RecurrentSchedule struct { + // TimeZone - the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time + TimeZone *string `json:"timeZone,omitempty"` + // Days - the collection of days that the profile takes effect on. Possible values are Sunday through Saturday. + Days *[]string `json:"days,omitempty"` + // Hours - A collection of hours that the profile takes effect on. Values supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + Hours *[]int32 `json:"hours,omitempty"` + // Minutes - A collection of minutes at which the profile takes effect at. + Minutes *[]int32 `json:"minutes,omitempty"` +} + +// Resource an azure resource object +type Resource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// ResourceForUpdate definition of ARM tracked top level resource properties for update operation. +type ResourceForUpdate struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ResourceForUpdate. +func (rfu ResourceForUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rfu.Tags != nil { + objectMap["tags"] = rfu.Tags + } + return json.Marshal(objectMap) +} + +// Response the response to a metrics query. +type Response struct { + autorest.Response `json:"-"` + // Cost - The integer value representing the relative cost of the query. + Cost *float64 `json:"cost,omitempty"` + // Timespan - The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + Timespan *string `json:"timespan,omitempty"` + // Interval - The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + Interval *string `json:"interval,omitempty"` + // Namespace - The namespace of the metrics being queried + Namespace *string `json:"namespace,omitempty"` + // Resourceregion - The region of the resource being queried for metrics. + Resourceregion *string `json:"resourceregion,omitempty"` + // Value - the value of the collection. + Value *[]Metric `json:"value,omitempty"` +} + +// ResponseWithError an error response from the API. +type ResponseWithError struct { + // Error - Error information. + Error *Error `json:"error,omitempty"` +} + +// RetentionPolicy specifies the retention policy for the log. +type RetentionPolicy struct { + // Enabled - a value indicating whether the retention policy is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Days - the number of days for the retention in days. A value of 0 will retain the events indefinitely. + Days *int32 `json:"days,omitempty"` +} + +// BasicRuleAction the action that is performed when the alert rule becomes active, and when an alert condition is +// resolved. +type BasicRuleAction interface { + AsRuleEmailAction() (*RuleEmailAction, bool) + AsRuleWebhookAction() (*RuleWebhookAction, bool) + AsRuleAction() (*RuleAction, bool) +} + +// RuleAction the action that is performed when the alert rule becomes active, and when an alert condition is +// resolved. +type RuleAction struct { + // OdataType - Possible values include: 'OdataTypeRuleAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction' + OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"` +} + +func unmarshalBasicRuleAction(body []byte) (BasicRuleAction, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction): + var rea RuleEmailAction + err := json.Unmarshal(body, &rea) + return rea, err + case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction): + var rwa RuleWebhookAction + err := json.Unmarshal(body, &rwa) + return rwa, err + default: + var ra RuleAction + err := json.Unmarshal(body, &ra) + return ra, err + } +} +func unmarshalBasicRuleActionArray(body []byte) ([]BasicRuleAction, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + raArray := make([]BasicRuleAction, len(rawMessages)) + + for index, rawMessage := range rawMessages { + ra, err := unmarshalBasicRuleAction(*rawMessage) + if err != nil { + return nil, err + } + raArray[index] = ra + } + return raArray, nil +} + +// MarshalJSON is the custom marshaler for RuleAction. +func (ra RuleAction) MarshalJSON() ([]byte, error) { + ra.OdataType = OdataTypeRuleAction + objectMap := make(map[string]interface{}) + if ra.OdataType != "" { + objectMap["odata.type"] = ra.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleEmailAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsRuleEmailAction() (*RuleEmailAction, bool) { + return nil, false +} + +// AsRuleWebhookAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) { + return nil, false +} + +// AsRuleAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsRuleAction() (*RuleAction, bool) { + return &ra, true +} + +// AsBasicRuleAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsBasicRuleAction() (BasicRuleAction, bool) { + return &ra, true +} + +// BasicRuleCondition the condition that results in the alert rule being activated. +type BasicRuleCondition interface { + AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) + AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) + AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) + AsRuleCondition() (*RuleCondition, bool) +} + +// RuleCondition the condition that results in the alert rule being activated. +type RuleCondition struct { + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` +} + +func unmarshalBasicRuleCondition(body []byte) (BasicRuleCondition, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition): + var trc ThresholdRuleCondition + err := json.Unmarshal(body, &trc) + return trc, err + case string(OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition): + var ltrc LocationThresholdRuleCondition + err := json.Unmarshal(body, <rc) + return ltrc, err + case string(OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition): + var merc ManagementEventRuleCondition + err := json.Unmarshal(body, &merc) + return merc, err + default: + var rc RuleCondition + err := json.Unmarshal(body, &rc) + return rc, err + } +} +func unmarshalBasicRuleConditionArray(body []byte) ([]BasicRuleCondition, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + rcArray := make([]BasicRuleCondition, len(rawMessages)) + + for index, rawMessage := range rawMessages { + rc, err := unmarshalBasicRuleCondition(*rawMessage) + if err != nil { + return nil, err + } + rcArray[index] = rc + } + return rcArray, nil +} + +// MarshalJSON is the custom marshaler for RuleCondition. +func (rc RuleCondition) MarshalJSON() ([]byte, error) { + rc.OdataType = OdataTypeRuleCondition + objectMap := make(map[string]interface{}) + objectMap["dataSource"] = rc.DataSource + if rc.OdataType != "" { + objectMap["odata.type"] = rc.OdataType + } + return json.Marshal(objectMap) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return nil, false +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return nil, false +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return nil, false +} + +// AsRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return &rc, true +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return &rc, true +} + +// UnmarshalJSON is the custom unmarshaler for RuleCondition struct. +func (rc *RuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "dataSource": + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*v) + if err != nil { + return err + } + rc.DataSource = dataSource + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicRuleCondition + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + rc.OdataType = odataType + } + } + } + + return nil +} + +// BasicRuleDataSource the resource from which the rule collects its data. +type BasicRuleDataSource interface { + AsRuleMetricDataSource() (*RuleMetricDataSource, bool) + AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) + AsRuleDataSource() (*RuleDataSource, bool) +} + +// RuleDataSource the resource from which the rule collects its data. +type RuleDataSource struct { + // ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + ResourceURI *string `json:"resourceUri,omitempty"` + // LegacyResourceID - the legacy resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + LegacyResourceID *string `json:"legacyResourceId,omitempty"` + // ResourceLocation - the location of the resource. + ResourceLocation *string `json:"resourceLocation,omitempty"` + // MetricNamespace - the namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource' + OdataType OdataType `json:"odata.type,omitempty"` +} + +func unmarshalBasicRuleDataSource(body []byte) (BasicRuleDataSource, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource): + var rmds RuleMetricDataSource + err := json.Unmarshal(body, &rmds) + return rmds, err + case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource): + var rmeds RuleManagementEventDataSource + err := json.Unmarshal(body, &rmeds) + return rmeds, err + default: + var rds RuleDataSource + err := json.Unmarshal(body, &rds) + return rds, err + } +} +func unmarshalBasicRuleDataSourceArray(body []byte) ([]BasicRuleDataSource, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + rdsArray := make([]BasicRuleDataSource, len(rawMessages)) + + for index, rawMessage := range rawMessages { + rds, err := unmarshalBasicRuleDataSource(*rawMessage) + if err != nil { + return nil, err + } + rdsArray[index] = rds + } + return rdsArray, nil +} + +// MarshalJSON is the custom marshaler for RuleDataSource. +func (rds RuleDataSource) MarshalJSON() ([]byte, error) { + rds.OdataType = OdataTypeRuleDataSource + objectMap := make(map[string]interface{}) + if rds.ResourceURI != nil { + objectMap["resourceUri"] = rds.ResourceURI + } + if rds.LegacyResourceID != nil { + objectMap["legacyResourceId"] = rds.LegacyResourceID + } + if rds.ResourceLocation != nil { + objectMap["resourceLocation"] = rds.ResourceLocation + } + if rds.MetricNamespace != nil { + objectMap["metricNamespace"] = rds.MetricNamespace + } + if rds.OdataType != "" { + objectMap["odata.type"] = rds.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) { + return nil, false +} + +// AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) { + return nil, false +} + +// AsRuleDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsRuleDataSource() (*RuleDataSource, bool) { + return &rds, true +} + +// AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) { + return &rds, true +} + +// RuleEmailAction specifies the action to send email when the rule condition is evaluated. The +// discriminator is always RuleEmailAction in this case. +type RuleEmailAction struct { + // SendToServiceOwners - Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. + SendToServiceOwners *bool `json:"sendToServiceOwners,omitempty"` + // CustomEmails - the list of administrator's custom email addresses to notify of the activation of the alert. + CustomEmails *[]string `json:"customEmails,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction' + OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleEmailAction. +func (rea RuleEmailAction) MarshalJSON() ([]byte, error) { + rea.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction + objectMap := make(map[string]interface{}) + if rea.SendToServiceOwners != nil { + objectMap["sendToServiceOwners"] = rea.SendToServiceOwners + } + if rea.CustomEmails != nil { + objectMap["customEmails"] = rea.CustomEmails + } + if rea.OdataType != "" { + objectMap["odata.type"] = rea.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleEmailAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsRuleEmailAction() (*RuleEmailAction, bool) { + return &rea, true +} + +// AsRuleWebhookAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) { + return nil, false +} + +// AsRuleAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsRuleAction() (*RuleAction, bool) { + return nil, false +} + +// AsBasicRuleAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsBasicRuleAction() (BasicRuleAction, bool) { + return &rea, true +} + +// RuleManagementEventClaimsDataSource the claims for a rule management event data source. +type RuleManagementEventClaimsDataSource struct { + // EmailAddress - the email address. + EmailAddress *string `json:"emailAddress,omitempty"` +} + +// RuleManagementEventDataSource a rule management event data source. The discriminator fields is always +// RuleManagementEventDataSource in this case. +type RuleManagementEventDataSource struct { + // EventName - the event name. + EventName *string `json:"eventName,omitempty"` + // EventSource - the event source. + EventSource *string `json:"eventSource,omitempty"` + // Level - the level. + Level *string `json:"level,omitempty"` + // OperationName - The name of the operation that should be checked for. If no name is provided, any operation will match. + OperationName *string `json:"operationName,omitempty"` + // ResourceGroupName - the resource group name. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // ResourceProviderName - the resource provider name. + ResourceProviderName *string `json:"resourceProviderName,omitempty"` + // Status - The status of the operation that should be checked for. If no status is provided, any status will match. + Status *string `json:"status,omitempty"` + // SubStatus - the substatus. + SubStatus *string `json:"subStatus,omitempty"` + // Claims - the claims. + Claims *RuleManagementEventClaimsDataSource `json:"claims,omitempty"` + // ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + ResourceURI *string `json:"resourceUri,omitempty"` + // LegacyResourceID - the legacy resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + LegacyResourceID *string `json:"legacyResourceId,omitempty"` + // ResourceLocation - the location of the resource. + ResourceLocation *string `json:"resourceLocation,omitempty"` + // MetricNamespace - the namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource' + OdataType OdataType `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) MarshalJSON() ([]byte, error) { + rmeds.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource + objectMap := make(map[string]interface{}) + if rmeds.EventName != nil { + objectMap["eventName"] = rmeds.EventName + } + if rmeds.EventSource != nil { + objectMap["eventSource"] = rmeds.EventSource + } + if rmeds.Level != nil { + objectMap["level"] = rmeds.Level + } + if rmeds.OperationName != nil { + objectMap["operationName"] = rmeds.OperationName + } + if rmeds.ResourceGroupName != nil { + objectMap["resourceGroupName"] = rmeds.ResourceGroupName + } + if rmeds.ResourceProviderName != nil { + objectMap["resourceProviderName"] = rmeds.ResourceProviderName + } + if rmeds.Status != nil { + objectMap["status"] = rmeds.Status + } + if rmeds.SubStatus != nil { + objectMap["subStatus"] = rmeds.SubStatus + } + if rmeds.Claims != nil { + objectMap["claims"] = rmeds.Claims + } + if rmeds.ResourceURI != nil { + objectMap["resourceUri"] = rmeds.ResourceURI + } + if rmeds.LegacyResourceID != nil { + objectMap["legacyResourceId"] = rmeds.LegacyResourceID + } + if rmeds.ResourceLocation != nil { + objectMap["resourceLocation"] = rmeds.ResourceLocation + } + if rmeds.MetricNamespace != nil { + objectMap["metricNamespace"] = rmeds.MetricNamespace + } + if rmeds.OdataType != "" { + objectMap["odata.type"] = rmeds.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) { + return nil, false +} + +// AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) { + return &rmeds, true +} + +// AsRuleDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsRuleDataSource() (*RuleDataSource, bool) { + return nil, false +} + +// AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) { + return &rmeds, true +} + +// RuleMetricDataSource a rule metric data source. The discriminator value is always RuleMetricDataSource +// in this case. +type RuleMetricDataSource struct { + // MetricName - the name of the metric that defines what the rule monitors. + MetricName *string `json:"metricName,omitempty"` + // ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + ResourceURI *string `json:"resourceUri,omitempty"` + // LegacyResourceID - the legacy resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + LegacyResourceID *string `json:"legacyResourceId,omitempty"` + // ResourceLocation - the location of the resource. + ResourceLocation *string `json:"resourceLocation,omitempty"` + // MetricNamespace - the namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource' + OdataType OdataType `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleMetricDataSource. +func (rmds RuleMetricDataSource) MarshalJSON() ([]byte, error) { + rmds.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource + objectMap := make(map[string]interface{}) + if rmds.MetricName != nil { + objectMap["metricName"] = rmds.MetricName + } + if rmds.ResourceURI != nil { + objectMap["resourceUri"] = rmds.ResourceURI + } + if rmds.LegacyResourceID != nil { + objectMap["legacyResourceId"] = rmds.LegacyResourceID + } + if rmds.ResourceLocation != nil { + objectMap["resourceLocation"] = rmds.ResourceLocation + } + if rmds.MetricNamespace != nil { + objectMap["metricNamespace"] = rmds.MetricNamespace + } + if rmds.OdataType != "" { + objectMap["odata.type"] = rmds.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) { + return &rmds, true +} + +// AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) { + return nil, false +} + +// AsRuleDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsRuleDataSource() (*RuleDataSource, bool) { + return nil, false +} + +// AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) { + return &rmds, true +} + +// RuleWebhookAction specifies the action to post to service when the rule condition is evaluated. The +// discriminator is always RuleWebhookAction in this case. +type RuleWebhookAction struct { + // ServiceURI - the service uri to Post the notification when the alert activates or resolves. + ServiceURI *string `json:"serviceUri,omitempty"` + // Properties - the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. + Properties map[string]*string `json:"properties"` + // OdataType - Possible values include: 'OdataTypeRuleAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction' + OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleWebhookAction. +func (rwa RuleWebhookAction) MarshalJSON() ([]byte, error) { + rwa.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction + objectMap := make(map[string]interface{}) + if rwa.ServiceURI != nil { + objectMap["serviceUri"] = rwa.ServiceURI + } + if rwa.Properties != nil { + objectMap["properties"] = rwa.Properties + } + if rwa.OdataType != "" { + objectMap["odata.type"] = rwa.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleEmailAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsRuleEmailAction() (*RuleEmailAction, bool) { + return nil, false +} + +// AsRuleWebhookAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) { + return &rwa, true +} + +// AsRuleAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsRuleAction() (*RuleAction, bool) { + return nil, false +} + +// AsBasicRuleAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsBasicRuleAction() (BasicRuleAction, bool) { + return &rwa, true +} + +// ScaleAction the parameters for the scaling action. +type ScaleAction struct { + // Direction - the scale direction. Whether the scaling action increases or decreases the number of instances. Possible values include: 'ScaleDirectionNone', 'ScaleDirectionIncrease', 'ScaleDirectionDecrease' + Direction ScaleDirection `json:"direction,omitempty"` + // Type - the type of action that should occur when the scale rule fires. Possible values include: 'ChangeCount', 'PercentChangeCount', 'ExactCount' + Type ScaleType `json:"type,omitempty"` + // Value - the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. + Value *string `json:"value,omitempty"` + // Cooldown - the amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + Cooldown *string `json:"cooldown,omitempty"` +} + +// ScaleCapacity the number of instances that can be used during this profile. +type ScaleCapacity struct { + // Minimum - the minimum number of instances for the resource. + Minimum *string `json:"minimum,omitempty"` + // Maximum - the maximum number of instances for the resource. The actual maximum number of instances is limited by the cores that are available in the subscription. + Maximum *string `json:"maximum,omitempty"` + // Default - the number of instances that will be set if metrics are not available for evaluation. The default is only used if the current instance count is lower than the default. + Default *string `json:"default,omitempty"` +} + +// ScaleRule a rule that provide the triggers and parameters for the scaling action. +type ScaleRule struct { + // MetricTrigger - the trigger that results in a scaling action. + MetricTrigger *MetricTrigger `json:"metricTrigger,omitempty"` + // ScaleAction - the parameters for the scaling action. + ScaleAction *ScaleAction `json:"scaleAction,omitempty"` +} + +// ScaleRuleMetricDimension specifies an auto scale rule metric dimension. +type ScaleRuleMetricDimension struct { + // DimensionName - Name of the dimension. + DimensionName *string `json:"DimensionName,omitempty"` + // Operator - the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. Possible values include: 'ScaleRuleMetricDimensionOperationTypeEquals', 'ScaleRuleMetricDimensionOperationTypeNotEquals' + Operator ScaleRuleMetricDimensionOperationType `json:"Operator,omitempty"` + // Values - list of dimension values. For example: ["App1","App2"]. + Values *[]string `json:"Values,omitempty"` +} + +// Schedule defines how often to run the search and the time interval. +type Schedule struct { + // FrequencyInMinutes - frequency (in minutes) at which rule condition should be evaluated. + FrequencyInMinutes *int32 `json:"frequencyInMinutes,omitempty"` + // TimeWindowInMinutes - Time window for which data needs to be fetched for query (should be greater than or equal to frequencyInMinutes). + TimeWindowInMinutes *int32 `json:"timeWindowInMinutes,omitempty"` +} + +// ScopedResource a private link scoped resource +type ScopedResource struct { + autorest.Response `json:"-"` + // ScopedResourceProperties - Resource properties. + *ScopedResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScopedResource. +func (sr ScopedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.ScopedResourceProperties != nil { + objectMap["properties"] = sr.ScopedResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScopedResource struct. +func (sr *ScopedResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var scopedResourceProperties ScopedResourceProperties + err = json.Unmarshal(*v, &scopedResourceProperties) + if err != nil { + return err + } + sr.ScopedResourceProperties = &scopedResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sr.Type = &typeVar + } + } + } + + return nil +} + +// ScopedResourceListResult a list of scoped resources in a private link scope. +type ScopedResourceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ScopedResource `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScopedResourceListResult. +func (srlr ScopedResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ScopedResourceListResultIterator provides access to a complete listing of ScopedResource values. +type ScopedResourceListResultIterator struct { + i int + page ScopedResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ScopedResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScopedResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ScopedResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ScopedResourceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ScopedResourceListResultIterator) Response() ScopedResourceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ScopedResourceListResultIterator) Value() ScopedResource { + if !iter.page.NotDone() { + return ScopedResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ScopedResourceListResultIterator type. +func NewScopedResourceListResultIterator(page ScopedResourceListResultPage) ScopedResourceListResultIterator { + return ScopedResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (srlr ScopedResourceListResult) IsEmpty() bool { + return srlr.Value == nil || len(*srlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (srlr ScopedResourceListResult) hasNextLink() bool { + return srlr.NextLink != nil && len(*srlr.NextLink) != 0 +} + +// scopedResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (srlr ScopedResourceListResult) scopedResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !srlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(srlr.NextLink))) +} + +// ScopedResourceListResultPage contains a page of ScopedResource values. +type ScopedResourceListResultPage struct { + fn func(context.Context, ScopedResourceListResult) (ScopedResourceListResult, error) + srlr ScopedResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ScopedResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScopedResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.srlr) + if err != nil { + return err + } + page.srlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ScopedResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ScopedResourceListResultPage) NotDone() bool { + return !page.srlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ScopedResourceListResultPage) Response() ScopedResourceListResult { + return page.srlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ScopedResourceListResultPage) Values() []ScopedResource { + if page.srlr.IsEmpty() { + return nil + } + return *page.srlr.Value +} + +// Creates a new instance of the ScopedResourceListResultPage type. +func NewScopedResourceListResultPage(cur ScopedResourceListResult, getNextPage func(context.Context, ScopedResourceListResult) (ScopedResourceListResult, error)) ScopedResourceListResultPage { + return ScopedResourceListResultPage{ + fn: getNextPage, + srlr: cur, + } +} + +// ScopedResourceProperties properties of a private link scoped resource. +type ScopedResourceProperties struct { + // LinkedResourceID - The resource id of the scoped Azure monitor resource. + LinkedResourceID *string `json:"linkedResourceId,omitempty"` + // ProvisioningState - READ-ONLY; State of the private endpoint connection. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScopedResourceProperties. +func (srp ScopedResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if srp.LinkedResourceID != nil { + objectMap["linkedResourceId"] = srp.LinkedResourceID + } + return json.Marshal(objectMap) +} + +// SenderAuthorization the authorization used by the user who has performed the operation that led to this +// event. This captures the RBAC properties of the event. These usually include the 'action', 'role' and +// the 'scope' +type SenderAuthorization struct { + // Action - the permissible actions. For instance: microsoft.support/supporttickets/write + Action *string `json:"action,omitempty"` + // Role - the role of the user. For instance: Subscription Admin + Role *string `json:"role,omitempty"` + // Scope - the scope. + Scope *string `json:"scope,omitempty"` +} + +// SingleBaseline the baseline values for a single sensitivity value. +type SingleBaseline struct { + // Sensitivity - the sensitivity of the baseline. Possible values include: 'Low', 'Medium', 'High' + Sensitivity BaselineSensitivity `json:"sensitivity,omitempty"` + // LowThresholds - The low thresholds of the baseline. + LowThresholds *[]float64 `json:"lowThresholds,omitempty"` + // HighThresholds - The high thresholds of the baseline. + HighThresholds *[]float64 `json:"highThresholds,omitempty"` +} + +// SingleMetricBaseline the baseline results of a single metric. +type SingleMetricBaseline struct { + // ID - The metric baseline Id. + ID *string `json:"id,omitempty"` + // Type - The resource type of the metric baseline resource. + Type *string `json:"type,omitempty"` + // Name - The name of the metric for which the baselines were retrieved. + Name *string `json:"name,omitempty"` + // MetricBaselinesProperties - The metric baseline properties of the metric. + *MetricBaselinesProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SingleMetricBaseline. +func (smb SingleMetricBaseline) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if smb.ID != nil { + objectMap["id"] = smb.ID + } + if smb.Type != nil { + objectMap["type"] = smb.Type + } + if smb.Name != nil { + objectMap["name"] = smb.Name + } + if smb.MetricBaselinesProperties != nil { + objectMap["properties"] = smb.MetricBaselinesProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SingleMetricBaseline struct. +func (smb *SingleMetricBaseline) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + smb.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + smb.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + smb.Name = &name + } + case "properties": + if v != nil { + var metricBaselinesProperties MetricBaselinesProperties + err = json.Unmarshal(*v, &metricBaselinesProperties) + if err != nil { + return err + } + smb.MetricBaselinesProperties = &metricBaselinesProperties + } + } + } + + return nil +} + +// SmsReceiver an SMS receiver. +type SmsReceiver struct { + // Name - The name of the SMS receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // CountryCode - The country code of the SMS receiver. + CountryCode *string `json:"countryCode,omitempty"` + // PhoneNumber - The phone number of the SMS receiver. + PhoneNumber *string `json:"phoneNumber,omitempty"` + // Status - READ-ONLY; The status of the receiver. Possible values include: 'ReceiverStatusNotSpecified', 'ReceiverStatusEnabled', 'ReceiverStatusDisabled' + Status ReceiverStatus `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for SmsReceiver. +func (sr SmsReceiver) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.Name != nil { + objectMap["name"] = sr.Name + } + if sr.CountryCode != nil { + objectMap["countryCode"] = sr.CountryCode + } + if sr.PhoneNumber != nil { + objectMap["phoneNumber"] = sr.PhoneNumber + } + return json.Marshal(objectMap) +} + +// Source specifies the log search query. +type Source struct { + // Query - Log search query. Required for action type - AlertingAction + Query *string `json:"query,omitempty"` + // AuthorizedResources - List of Resource referred into query + AuthorizedResources *[]string `json:"authorizedResources,omitempty"` + // DataSourceID - The resource uri over which log search query is to be run. + DataSourceID *string `json:"dataSourceId,omitempty"` + // QueryType - Set value to 'ResultCount'. Possible values include: 'ResultCount' + QueryType QueryType `json:"queryType,omitempty"` +} + +// SyslogDataSource definition of which syslog data will be collected and how it will be collected. +// Only collected from Linux machines. +type SyslogDataSource struct { + // Streams - List of streams that this data source will be sent to. + // A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. + Streams *[]KnownSyslogDataSourceStreams `json:"streams,omitempty"` + // FacilityNames - The list of facility names. + FacilityNames *[]KnownSyslogDataSourceFacilityNames `json:"facilityNames,omitempty"` + // LogLevels - The log levels to collect. + LogLevels *[]KnownSyslogDataSourceLogLevels `json:"logLevels,omitempty"` + // Name - A friendly name for the data source. + // This name should be unique across all data sources (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TagsResource a container holding only the Tags for a resource, allowing the user to update the tags on a +// PrivateLinkScope instance. +type TagsResource struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TagsResource. +func (tr TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// ThresholdRuleCondition a rule condition based on a metric crossing a threshold. +type ThresholdRuleCondition struct { + // Operator - the operator used to compare the data and the threshold. Possible values include: 'ConditionOperatorGreaterThan', 'ConditionOperatorGreaterThanOrEqual', 'ConditionOperatorLessThan', 'ConditionOperatorLessThanOrEqual' + Operator ConditionOperator `json:"operator,omitempty"` + // Threshold - the threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + WindowSize *string `json:"windowSize,omitempty"` + // TimeAggregation - the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible values include: 'TimeAggregationOperatorAverage', 'TimeAggregationOperatorMinimum', 'TimeAggregationOperatorMaximum', 'TimeAggregationOperatorTotal', 'TimeAggregationOperatorLast' + TimeAggregation TimeAggregationOperator `json:"timeAggregation,omitempty"` + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) MarshalJSON() ([]byte, error) { + trc.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition + objectMap := make(map[string]interface{}) + if trc.Operator != "" { + objectMap["operator"] = trc.Operator + } + if trc.Threshold != nil { + objectMap["threshold"] = trc.Threshold + } + if trc.WindowSize != nil { + objectMap["windowSize"] = trc.WindowSize + } + if trc.TimeAggregation != "" { + objectMap["timeAggregation"] = trc.TimeAggregation + } + objectMap["dataSource"] = trc.DataSource + if trc.OdataType != "" { + objectMap["odata.type"] = trc.OdataType + } + return json.Marshal(objectMap) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return &trc, true +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return nil, false +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return nil, false +} + +// AsRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return nil, false +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return &trc, true +} + +// UnmarshalJSON is the custom unmarshaler for ThresholdRuleCondition struct. +func (trc *ThresholdRuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "operator": + if v != nil { + var operator ConditionOperator + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + trc.Operator = operator + } + case "threshold": + if v != nil { + var threshold float64 + err = json.Unmarshal(*v, &threshold) + if err != nil { + return err + } + trc.Threshold = &threshold + } + case "windowSize": + if v != nil { + var windowSize string + err = json.Unmarshal(*v, &windowSize) + if err != nil { + return err + } + trc.WindowSize = &windowSize + } + case "timeAggregation": + if v != nil { + var timeAggregation TimeAggregationOperator + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + trc.TimeAggregation = timeAggregation + } + case "dataSource": + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*v) + if err != nil { + return err + } + trc.DataSource = dataSource + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicRuleCondition + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + trc.OdataType = odataType + } + } + } + + return nil +} + +// TimeSeriesBaseline the baseline values for a single time series. +type TimeSeriesBaseline struct { + // Aggregation - The aggregation type of the metric. + Aggregation *string `json:"aggregation,omitempty"` + // Dimensions - The dimensions of this time series. + Dimensions *[]MetricSingleDimension `json:"dimensions,omitempty"` + // Timestamps - The list of timestamps of the baselines. + Timestamps *[]date.Time `json:"timestamps,omitempty"` + // Data - The baseline values for each sensitivity. + Data *[]SingleBaseline `json:"data,omitempty"` + // MetadataValues - The baseline metadata values. + MetadataValues *[]BaselineMetadata `json:"metadataValues,omitempty"` +} + +// TimeSeriesElement a time series result type. The discriminator value is always TimeSeries in this case. +type TimeSeriesElement struct { + // Metadatavalues - the metadata values returned if $filter was specified in the call. + Metadatavalues *[]MetadataValue `json:"metadatavalues,omitempty"` + // Data - An array of data points representing the metric values. This is only returned if a result type of data is specified. + Data *[]MetricValue `json:"data,omitempty"` +} + +// TimeWindow a specific date-time for the profile. +type TimeWindow struct { + // TimeZone - the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time + TimeZone *string `json:"timeZone,omitempty"` + // Start - the start time for the profile in ISO 8601 format. + Start *date.Time `json:"start,omitempty"` + // End - the end time for the profile in ISO 8601 format. + End *date.Time `json:"end,omitempty"` +} + +// TriggerCondition the condition that results in the Log Search rule. +type TriggerCondition struct { + // ThresholdOperator - Evaluation operation for rule - 'GreaterThan' or 'LessThan. Possible values include: 'ConditionalOperatorGreaterThanOrEqual', 'ConditionalOperatorLessThanOrEqual', 'ConditionalOperatorGreaterThan', 'ConditionalOperatorLessThan', 'ConditionalOperatorEqual' + ThresholdOperator ConditionalOperator `json:"thresholdOperator,omitempty"` + // Threshold - Result or count threshold based on which rule should be triggered. + Threshold *float64 `json:"threshold,omitempty"` + // MetricTrigger - Trigger condition for metric query rule + MetricTrigger *LogMetricTrigger `json:"metricTrigger,omitempty"` +} + +// VMInsightsOnboardingStatus VM Insights onboarding status for a resource. +type VMInsightsOnboardingStatus struct { + autorest.Response `json:"-"` + // VMInsightsOnboardingStatusProperties - Resource properties. + *VMInsightsOnboardingStatusProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VMInsightsOnboardingStatus. +func (vios VMInsightsOnboardingStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vios.VMInsightsOnboardingStatusProperties != nil { + objectMap["properties"] = vios.VMInsightsOnboardingStatusProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VMInsightsOnboardingStatus struct. +func (vios *VMInsightsOnboardingStatus) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var VMInsightsOnboardingStatusProperties VMInsightsOnboardingStatusProperties + err = json.Unmarshal(*v, &VMInsightsOnboardingStatusProperties) + if err != nil { + return err + } + vios.VMInsightsOnboardingStatusProperties = &VMInsightsOnboardingStatusProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vios.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vios.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vios.Type = &typeVar + } + } + } + + return nil +} + +// VMInsightsOnboardingStatusProperties resource properties. +type VMInsightsOnboardingStatusProperties struct { + // ResourceID - Azure Resource Manager identifier of the resource whose onboarding status is being represented. + ResourceID *string `json:"resourceId,omitempty"` + // OnboardingStatus - The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource under it is onboarded. Possible values include: 'Onboarded', 'NotOnboarded', 'Unknown' + OnboardingStatus OnboardingStatus `json:"onboardingStatus,omitempty"` + // DataStatus - The status of VM Insights data from the resource. When reported as `present` the data array will contain information about the data containers to which data for the specified resource is being routed. Possible values include: 'Present', 'NotPresent' + DataStatus DataStatus `json:"dataStatus,omitempty"` + // Data - Containers that currently store VM Insights data for the specified resource. + Data *[]DataContainer `json:"data,omitempty"` +} + +// VoiceReceiver a voice receiver. +type VoiceReceiver struct { + // Name - The name of the voice receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // CountryCode - The country code of the voice receiver. + CountryCode *string `json:"countryCode,omitempty"` + // PhoneNumber - The phone number of the voice receiver. + PhoneNumber *string `json:"phoneNumber,omitempty"` +} + +// WebhookNotification webhook notification of an autoscale event. +type WebhookNotification struct { + // ServiceURI - the service address to receive the notification. + ServiceURI *string `json:"serviceUri,omitempty"` + // Properties - a property bag of settings. This value can be empty. + Properties map[string]*string `json:"properties"` +} + +// MarshalJSON is the custom marshaler for WebhookNotification. +func (wn WebhookNotification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wn.ServiceURI != nil { + objectMap["serviceUri"] = wn.ServiceURI + } + if wn.Properties != nil { + objectMap["properties"] = wn.Properties + } + return json.Marshal(objectMap) +} + +// WebhookReceiver a webhook receiver. +type WebhookReceiver struct { + // Name - The name of the webhook receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // ServiceURI - The URI where webhooks should be sent. + ServiceURI *string `json:"serviceUri,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` + // UseAadAuth - Indicates whether or not use AAD authentication. + UseAadAuth *bool `json:"useAadAuth,omitempty"` + // ObjectID - Indicates the webhook app object Id for aad auth. + ObjectID *string `json:"objectId,omitempty"` + // IdentifierURI - Indicates the identifier uri for aad auth. + IdentifierURI *string `json:"identifierUri,omitempty"` + // TenantID - Indicates the tenant id for aad auth. + TenantID *string `json:"tenantId,omitempty"` +} + +// WebtestLocationAvailabilityCriteria specifies the metric alert rule criteria for a web test resource. +type WebtestLocationAvailabilityCriteria struct { + // WebTestID - The Application Insights web test Id. + WebTestID *string `json:"webTestId,omitempty"` + // ComponentID - The Application Insights resource Id. + ComponentID *string `json:"componentId,omitempty"` + // FailedLocationCount - The number of failed locations. + FailedLocationCount *float64 `json:"failedLocationCount,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria' + OdataType OdataTypeBasicMetricAlertCriteria `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) MarshalJSON() ([]byte, error) { + wlac.OdataType = OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria + objectMap := make(map[string]interface{}) + if wlac.WebTestID != nil { + objectMap["webTestId"] = wlac.WebTestID + } + if wlac.ComponentID != nil { + objectMap["componentId"] = wlac.ComponentID + } + if wlac.FailedLocationCount != nil { + objectMap["failedLocationCount"] = wlac.FailedLocationCount + } + if wlac.OdataType != "" { + objectMap["odata.type"] = wlac.OdataType + } + for k, v := range wlac.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricAlertSingleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) AsMetricAlertSingleResourceMultipleMetricCriteria() (*MetricAlertSingleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsWebtestLocationAvailabilityCriteria is the BasicMetricAlertCriteria implementation for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) { + return &wlac, true +} + +// AsMetricAlertMultipleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) AsMetricAlertMultipleResourceMultipleMetricCriteria() (*MetricAlertMultipleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsMetricAlertCriteria is the BasicMetricAlertCriteria implementation for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) AsMetricAlertCriteria() (*MetricAlertCriteria, bool) { + return nil, false +} + +// AsBasicMetricAlertCriteria is the BasicMetricAlertCriteria implementation for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) AsBasicMetricAlertCriteria() (BasicMetricAlertCriteria, bool) { + return &wlac, true +} + +// UnmarshalJSON is the custom unmarshaler for WebtestLocationAvailabilityCriteria struct. +func (wlac *WebtestLocationAvailabilityCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "webTestId": + if v != nil { + var webTestID string + err = json.Unmarshal(*v, &webTestID) + if err != nil { + return err + } + wlac.WebTestID = &webTestID + } + case "componentId": + if v != nil { + var componentID string + err = json.Unmarshal(*v, &componentID) + if err != nil { + return err + } + wlac.ComponentID = &componentID + } + case "failedLocationCount": + if v != nil { + var failedLocationCount float64 + err = json.Unmarshal(*v, &failedLocationCount) + if err != nil { + return err + } + wlac.FailedLocationCount = &failedLocationCount + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if wlac.AdditionalProperties == nil { + wlac.AdditionalProperties = make(map[string]interface{}) + } + wlac.AdditionalProperties[k] = additionalProperties + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicMetricAlertCriteria + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + wlac.OdataType = odataType + } + } + } + + return nil +} + +// WindowsEventLogDataSource definition of which Windows Event Log events will be collected and how they +// will be collected. +// Only collected from Windows machines. +type WindowsEventLogDataSource struct { + // Streams - List of streams that this data source will be sent to. + // A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. + Streams *[]KnownWindowsEventLogDataSourceStreams `json:"streams,omitempty"` + // XPathQueries - A list of Windows Event Log queries in XPATH format. + XPathQueries *[]string `json:"xPathQueries,omitempty"` + // Name - A friendly name for the data source. + // This name should be unique across all data sources (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// WorkspaceInfo information about a Log Analytics Workspace. +type WorkspaceInfo struct { + // ID - Azure Resource Manager identifier of the Log Analytics Workspace. + ID *string `json:"id,omitempty"` + // Location - Location of the Log Analytics workspace. + Location *string `json:"location,omitempty"` + // WorkspaceInfoProperties - Resource properties. + *WorkspaceInfoProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkspaceInfo. +func (wi WorkspaceInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wi.ID != nil { + objectMap["id"] = wi.ID + } + if wi.Location != nil { + objectMap["location"] = wi.Location + } + if wi.WorkspaceInfoProperties != nil { + objectMap["properties"] = wi.WorkspaceInfoProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkspaceInfo struct. +func (wi *WorkspaceInfo) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wi.ID = &ID + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + wi.Location = &location + } + case "properties": + if v != nil { + var workspaceInfoProperties WorkspaceInfoProperties + err = json.Unmarshal(*v, &workspaceInfoProperties) + if err != nil { + return err + } + wi.WorkspaceInfoProperties = &workspaceInfoProperties + } + } + } + + return nil +} + +// WorkspaceInfoProperties resource properties. +type WorkspaceInfoProperties struct { + // CustomerID - Log Analytics workspace identifier. + CustomerID *string `json:"customerId,omitempty"` +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/operations.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/operations.go new file mode 100644 index 000000000000..3f82351c7f23 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/operations.go @@ -0,0 +1,98 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the monitor Management Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available operations from Microsoft.Insights provider. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/microsoft.insights/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/privateendpointconnections.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privateendpointconnections.go new file mode 100644 index 000000000000..dbbf6b656f55 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privateendpointconnections.go @@ -0,0 +1,433 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsClient is the monitor Management Client +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate approve or reject a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState.Status", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState.Description", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("insights.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, scopeName, privateEndpointConnectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateEndpointConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, scopeName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateEndpointConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, scopeName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPrivateLinkScope gets all private endpoint connections on a private link scope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +func (client PrivateEndpointConnectionsClient) ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateEndpointConnectionsClient", "ListByPrivateLinkScope", err.Error()) + } + + result.fn = client.listByPrivateLinkScopeNextResults + req, err := client.ListByPrivateLinkScopePreparer(ctx, resourceGroupName, scopeName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "ListByPrivateLinkScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "ListByPrivateLinkScope", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "ListByPrivateLinkScope", resp, "Failure responding to request") + return + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPrivateLinkScopePreparer prepares the ListByPrivateLinkScope request. +func (client PrivateEndpointConnectionsClient) ListByPrivateLinkScopePreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPrivateLinkScopeSender sends the ListByPrivateLinkScope request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) ListByPrivateLinkScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPrivateLinkScopeResponder handles the response to the ListByPrivateLinkScope request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListByPrivateLinkScopeResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPrivateLinkScopeNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsClient) listByPrivateLinkScopeNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "listByPrivateLinkScopeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "listByPrivateLinkScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "listByPrivateLinkScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPrivateLinkScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsClient) ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByPrivateLinkScope(ctx, resourceGroupName, scopeName) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkresources.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkresources.go new file mode 100644 index 000000000000..02157f85d6c4 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkresources.go @@ -0,0 +1,247 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesClient is the monitor Management Client +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// groupName - the name of the private link resource. +func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, scopeName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, scopeName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, scopeName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPrivateLinkScope gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +func (client PrivateLinkResourcesClient) ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result PrivateLinkResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.plrlr.Response.Response != nil { + sc = result.plrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkResourcesClient", "ListByPrivateLinkScope", err.Error()) + } + + result.fn = client.listByPrivateLinkScopeNextResults + req, err := client.ListByPrivateLinkScopePreparer(ctx, resourceGroupName, scopeName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "ListByPrivateLinkScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.plrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "ListByPrivateLinkScope", resp, "Failure sending request") + return + } + + result.plrlr, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "ListByPrivateLinkScope", resp, "Failure responding to request") + return + } + if result.plrlr.hasNextLink() && result.plrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPrivateLinkScopePreparer prepares the ListByPrivateLinkScope request. +func (client PrivateLinkResourcesClient) ListByPrivateLinkScopePreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPrivateLinkScopeSender sends the ListByPrivateLinkScope request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListByPrivateLinkScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPrivateLinkScopeResponder handles the response to the ListByPrivateLinkScope request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListByPrivateLinkScopeResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPrivateLinkScopeNextResults retrieves the next set of results, if any. +func (client PrivateLinkResourcesClient) listByPrivateLinkScopeNextResults(ctx context.Context, lastResults PrivateLinkResourceListResult) (result PrivateLinkResourceListResult, err error) { + req, err := lastResults.privateLinkResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "listByPrivateLinkScopeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "listByPrivateLinkScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "listByPrivateLinkScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPrivateLinkScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkResourcesClient) ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result PrivateLinkResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByPrivateLinkScope(ctx, resourceGroupName, scopeName) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopedresources.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopedresources.go new file mode 100644 index 000000000000..9e65301c003d --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopedresources.go @@ -0,0 +1,426 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkScopedResourcesClient is the monitor Management Client +type PrivateLinkScopedResourcesClient struct { + BaseClient +} + +// NewPrivateLinkScopedResourcesClient creates an instance of the PrivateLinkScopedResourcesClient client. +func NewPrivateLinkScopedResourcesClient(subscriptionID string) PrivateLinkScopedResourcesClient { + return NewPrivateLinkScopedResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkScopedResourcesClientWithBaseURI creates an instance of the PrivateLinkScopedResourcesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateLinkScopedResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkScopedResourcesClient { + return PrivateLinkScopedResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate approve or reject a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// name - the name of the scoped resource object. +func (client PrivateLinkScopedResourcesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, name string, parameters ScopedResource) (result PrivateLinkScopedResourcesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopedResourcesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopedResourcesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, scopeName, name, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateLinkScopedResourcesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, scopeName string, name string, parameters ScopedResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopedResourcesClient) CreateOrUpdateSender(req *http.Request) (future PrivateLinkScopedResourcesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopedResourcesClient) CreateOrUpdateResponder(resp *http.Response) (result ScopedResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// name - the name of the scoped resource object. +func (client PrivateLinkScopedResourcesClient) Delete(ctx context.Context, resourceGroupName string, scopeName string, name string) (result PrivateLinkScopedResourcesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopedResourcesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopedResourcesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, scopeName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateLinkScopedResourcesClient) DeletePreparer(ctx context.Context, resourceGroupName string, scopeName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopedResourcesClient) DeleteSender(req *http.Request) (future PrivateLinkScopedResourcesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopedResourcesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a scoped resource in a private link scope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// name - the name of the scoped resource object. +func (client PrivateLinkScopedResourcesClient) Get(ctx context.Context, resourceGroupName string, scopeName string, name string) (result ScopedResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopedResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopedResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, scopeName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkScopedResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, scopeName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopedResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopedResourcesClient) GetResponder(resp *http.Response) (result ScopedResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPrivateLinkScope gets all private endpoint connections on a private link scope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +func (client PrivateLinkScopedResourcesClient) ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result ScopedResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopedResourcesClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.srlr.Response.Response != nil { + sc = result.srlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopedResourcesClient", "ListByPrivateLinkScope", err.Error()) + } + + result.fn = client.listByPrivateLinkScopeNextResults + req, err := client.ListByPrivateLinkScopePreparer(ctx, resourceGroupName, scopeName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "ListByPrivateLinkScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.srlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "ListByPrivateLinkScope", resp, "Failure sending request") + return + } + + result.srlr, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "ListByPrivateLinkScope", resp, "Failure responding to request") + return + } + if result.srlr.hasNextLink() && result.srlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPrivateLinkScopePreparer prepares the ListByPrivateLinkScope request. +func (client PrivateLinkScopedResourcesClient) ListByPrivateLinkScopePreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPrivateLinkScopeSender sends the ListByPrivateLinkScope request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopedResourcesClient) ListByPrivateLinkScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPrivateLinkScopeResponder handles the response to the ListByPrivateLinkScope request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopedResourcesClient) ListByPrivateLinkScopeResponder(resp *http.Response) (result ScopedResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPrivateLinkScopeNextResults retrieves the next set of results, if any. +func (client PrivateLinkScopedResourcesClient) listByPrivateLinkScopeNextResults(ctx context.Context, lastResults ScopedResourceListResult) (result ScopedResourceListResult, err error) { + req, err := lastResults.scopedResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "listByPrivateLinkScopeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "listByPrivateLinkScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "listByPrivateLinkScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPrivateLinkScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkScopedResourcesClient) ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result ScopedResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopedResourcesClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByPrivateLinkScope(ctx, resourceGroupName, scopeName) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopeoperationstatus.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopeoperationstatus.go new file mode 100644 index 000000000000..a29fa9edf886 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopeoperationstatus.go @@ -0,0 +1,118 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkScopeOperationStatusClient is the monitor Management Client +type PrivateLinkScopeOperationStatusClient struct { + BaseClient +} + +// NewPrivateLinkScopeOperationStatusClient creates an instance of the PrivateLinkScopeOperationStatusClient client. +func NewPrivateLinkScopeOperationStatusClient(subscriptionID string) PrivateLinkScopeOperationStatusClient { + return NewPrivateLinkScopeOperationStatusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkScopeOperationStatusClientWithBaseURI creates an instance of the PrivateLinkScopeOperationStatusClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewPrivateLinkScopeOperationStatusClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkScopeOperationStatusClient { + return PrivateLinkScopeOperationStatusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the status of an azure asynchronous operation associated with a private link scope operation. +// Parameters: +// asyncOperationID - the operation Id. +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client PrivateLinkScopeOperationStatusClient) Get(ctx context.Context, asyncOperationID string, resourceGroupName string) (result OperationStatus, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopeOperationStatusClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopeOperationStatusClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, asyncOperationID, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopeOperationStatusClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopeOperationStatusClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopeOperationStatusClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkScopeOperationStatusClient) GetPreparer(ctx context.Context, asyncOperationID string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "asyncOperationId": autorest.Encode("path", asyncOperationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopeOperationStatusClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopeOperationStatusClient) GetResponder(resp *http.Response) (result OperationStatus, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopes.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopes.go new file mode 100644 index 000000000000..8f123de6c236 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopes.go @@ -0,0 +1,628 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkScopesClient is the monitor Management Client +type PrivateLinkScopesClient struct { + BaseClient +} + +// NewPrivateLinkScopesClient creates an instance of the PrivateLinkScopesClient client. +func NewPrivateLinkScopesClient(subscriptionID string) PrivateLinkScopesClient { + return NewPrivateLinkScopesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkScopesClientWithBaseURI creates an instance of the PrivateLinkScopesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkScopesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkScopesClient { + return PrivateLinkScopesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different value for +// InstrumentationKey nor AppId in the Put operation. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// azureMonitorPrivateLinkScopePayload - properties that need to be specified to create or update a Azure +// Monitor PrivateLinkScope. +func (client PrivateLinkScopesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, azureMonitorPrivateLinkScopePayload AzureMonitorPrivateLinkScope) (result AzureMonitorPrivateLinkScope, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: azureMonitorPrivateLinkScopePayload, + Constraints: []validation.Constraint{{Target: "azureMonitorPrivateLinkScopePayload.AzureMonitorPrivateLinkScopeProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, scopeName, azureMonitorPrivateLinkScopePayload) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateLinkScopesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, scopeName string, azureMonitorPrivateLinkScopePayload AzureMonitorPrivateLinkScope) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", pathParameters), + autorest.WithJSON(azureMonitorPrivateLinkScopePayload), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) CreateOrUpdateResponder(resp *http.Response) (result AzureMonitorPrivateLinkScope, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a Azure Monitor PrivateLinkScope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +func (client PrivateLinkScopesClient) Delete(ctx context.Context, resourceGroupName string, scopeName string) (result PrivateLinkScopesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, scopeName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateLinkScopesClient) DeletePreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopesClient) DeleteSender(req *http.Request) (future PrivateLinkScopesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns a Azure Monitor PrivateLinkScope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +func (client PrivateLinkScopesClient) Get(ctx context.Context, resourceGroupName string, scopeName string) (result AzureMonitorPrivateLinkScope, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, scopeName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkScopesClient) GetPreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) GetResponder(resp *http.Response) (result AzureMonitorPrivateLinkScope, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all Azure Monitor PrivateLinkScopes within a subscription. +func (client PrivateLinkScopesClient) List(ctx context.Context) (result AzureMonitorPrivateLinkScopeListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.List") + defer func() { + sc := -1 + if result.amplslr.Response.Response != nil { + sc = result.amplslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.amplslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "List", resp, "Failure sending request") + return + } + + result.amplslr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "List", resp, "Failure responding to request") + return + } + if result.amplslr.hasNextLink() && result.amplslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkScopesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) ListResponder(resp *http.Response) (result AzureMonitorPrivateLinkScopeListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateLinkScopesClient) listNextResults(ctx context.Context, lastResults AzureMonitorPrivateLinkScopeListResult) (result AzureMonitorPrivateLinkScopeListResult, err error) { + req, err := lastResults.azureMonitorPrivateLinkScopeListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkScopesClient) ListComplete(ctx context.Context) (result AzureMonitorPrivateLinkScopeListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of Azure Monitor PrivateLinkScopes within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client PrivateLinkScopesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AzureMonitorPrivateLinkScopeListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.amplslr.Response.Response != nil { + sc = result.amplslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.amplslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.amplslr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.amplslr.hasNextLink() && result.amplslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client PrivateLinkScopesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) ListByResourceGroupResponder(resp *http.Response) (result AzureMonitorPrivateLinkScopeListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client PrivateLinkScopesClient) listByResourceGroupNextResults(ctx context.Context, lastResults AzureMonitorPrivateLinkScopeListResult) (result AzureMonitorPrivateLinkScopeListResult, err error) { + req, err := lastResults.azureMonitorPrivateLinkScopeListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkScopesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AzureMonitorPrivateLinkScopeListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// UpdateTags updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// privateLinkScopeTags - updated tag information to set into the PrivateLinkScope instance. +func (client PrivateLinkScopesClient) UpdateTags(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags TagsResource) (result AzureMonitorPrivateLinkScope, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.UpdateTags") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "UpdateTags", err.Error()) + } + + req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, scopeName, privateLinkScopeTags) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "UpdateTags", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateTagsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "UpdateTags", resp, "Failure sending request") + return + } + + result, err = client.UpdateTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "UpdateTags", resp, "Failure responding to request") + return + } + + return +} + +// UpdateTagsPreparer prepares the UpdateTags request. +func (client PrivateLinkScopesClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags TagsResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", pathParameters), + autorest.WithJSON(privateLinkScopeTags), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateTagsSender sends the UpdateTags request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopesClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateTagsResponder handles the response to the UpdateTags request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) UpdateTagsResponder(resp *http.Response) (result AzureMonitorPrivateLinkScope, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/scheduledqueryrules.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/scheduledqueryrules.go new file mode 100644 index 000000000000..d619338b4e0d --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/scheduledqueryrules.go @@ -0,0 +1,558 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ScheduledQueryRulesClient is the monitor Management Client +type ScheduledQueryRulesClient struct { + BaseClient +} + +// NewScheduledQueryRulesClient creates an instance of the ScheduledQueryRulesClient client. +func NewScheduledQueryRulesClient(subscriptionID string) ScheduledQueryRulesClient { + return NewScheduledQueryRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewScheduledQueryRulesClientWithBaseURI creates an instance of the ScheduledQueryRulesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewScheduledQueryRulesClientWithBaseURI(baseURI string, subscriptionID string) ScheduledQueryRulesClient { + return ScheduledQueryRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an log search rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// parameters - the parameters of the rule to create or update. +func (client ScheduledQueryRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResource) (result LogSearchRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.LogSearchRule", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogSearchRule.Source", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogSearchRule.Source.DataSourceID", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.LogSearchRule.Schedule", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.LogSearchRule.Schedule.FrequencyInMinutes", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogSearchRule.Schedule.TimeWindowInMinutes", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ScheduledQueryRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduledQueryRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) CreateOrUpdateResponder(resp *http.Response) (result LogSearchRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a Log Search rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client ScheduledQueryRulesClient) Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ScheduledQueryRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduledQueryRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an Log Search rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client ScheduledQueryRulesClient) Get(ctx context.Context, resourceGroupName string, ruleName string) (result LogSearchRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ScheduledQueryRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduledQueryRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) GetResponder(resp *http.Response) (result LogSearchRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list the Log Search rules within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// filter - the filter to apply on the operation. For more information please see +// https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx +func (client ScheduledQueryRulesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result LogSearchRuleResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ScheduledQueryRulesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduledQueryRulesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) ListByResourceGroupResponder(resp *http.Response) (result LogSearchRuleResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription list the Log Search rules within a subscription group. +// Parameters: +// filter - the filter to apply on the operation. For more information please see +// https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx +func (client ScheduledQueryRulesClient) ListBySubscription(ctx context.Context, filter string) (result LogSearchRuleResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ScheduledQueryRulesClient) ListBySubscriptionPreparer(ctx context.Context, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/scheduledQueryRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduledQueryRulesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) ListBySubscriptionResponder(resp *http.Response) (result LogSearchRuleResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update log search Rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// parameters - the parameters of the rule to update. +func (client ScheduledQueryRulesClient) Update(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResourcePatch) (result LogSearchRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ScheduledQueryRulesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduledQueryRulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) UpdateResponder(resp *http.Response) (result LogSearchRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/tenantactivitylogs.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/tenantactivitylogs.go new file mode 100644 index 000000000000..7501f047bb38 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/tenantactivitylogs.go @@ -0,0 +1,168 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TenantActivityLogsClient is the monitor Management Client +type TenantActivityLogsClient struct { + BaseClient +} + +// NewTenantActivityLogsClient creates an instance of the TenantActivityLogsClient client. +func NewTenantActivityLogsClient(subscriptionID string) TenantActivityLogsClient { + return NewTenantActivityLogsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTenantActivityLogsClientWithBaseURI creates an instance of the TenantActivityLogsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewTenantActivityLogsClientWithBaseURI(baseURI string, subscriptionID string) TenantActivityLogsClient { + return TenantActivityLogsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List gets the Activity Logs for the Tenant.
Everything that is applicable to the API to get the Activity Logs for +// the subscription is applicable to this API (the parameters, $filter, etc.).
One thing to point out here is that +// this API does *not* retrieve the logs at the individual subscription of the tenant but only surfaces the logs that +// were generated at the tenant level. +// Parameters: +// filter - reduces the set of data collected.
The **$filter** is very restricted and allows only the +// following patterns.
- List events for a resource group: $filter=eventTimestamp ge '' and +// eventTimestamp le '' and eventChannels eq 'Admin, Operation' and resourceGroupName eq +// ''.
- List events for resource: $filter=eventTimestamp ge '' and +// eventTimestamp le '' and eventChannels eq 'Admin, Operation' and resourceUri eq +// ''.
- List events for a subscription: $filter=eventTimestamp ge '' and +// eventTimestamp le '' and eventChannels eq 'Admin, Operation'.
- List events for a resource +// provider: $filter=eventTimestamp ge '' and eventTimestamp le '' and eventChannels eq +// 'Admin, Operation' and resourceProvider eq ''.
- List events for a correlation Id: +// api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le +// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq +// ''.
**NOTE**: No other syntax is allowed. +// selectParameter - used to fetch events with only the given properties.
The **$select** argument is a +// comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, +// *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, +// *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, +// *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* +func (client TenantActivityLogsClient) List(ctx context.Context, filter string, selectParameter string) (result EventDataCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantActivityLogsClient.List") + defer func() { + sc := -1 + if result.edc.Response.Response != nil { + sc = result.edc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, filter, selectParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.TenantActivityLogsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.edc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.TenantActivityLogsClient", "List", resp, "Failure sending request") + return + } + + result.edc, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.TenantActivityLogsClient", "List", resp, "Failure responding to request") + return + } + if result.edc.hasNextLink() && result.edc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client TenantActivityLogsClient) ListPreparer(ctx context.Context, filter string, selectParameter string) (*http.Request, error) { + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/microsoft.insights/eventtypes/management/values"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client TenantActivityLogsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client TenantActivityLogsClient) ListResponder(resp *http.Response) (result EventDataCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client TenantActivityLogsClient) listNextResults(ctx context.Context, lastResults EventDataCollection) (result EventDataCollection, err error) { + req, err := lastResults.eventDataCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.TenantActivityLogsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.TenantActivityLogsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.TenantActivityLogsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client TenantActivityLogsClient) ListComplete(ctx context.Context, filter string, selectParameter string) (result EventDataCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantActivityLogsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, filter, selectParameter) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/version.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/version.go new file mode 100644 index 000000000000..60957f79ddd4 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/version.go @@ -0,0 +1,19 @@ +package insights + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " insights/2021-04-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/vminsights.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/vminsights.go new file mode 100644 index 000000000000..3787cb6fc53e --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/vminsights.go @@ -0,0 +1,105 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// VMInsightsClient is the monitor Management Client +type VMInsightsClient struct { + BaseClient +} + +// NewVMInsightsClient creates an instance of the VMInsightsClient client. +func NewVMInsightsClient(subscriptionID string) VMInsightsClient { + return NewVMInsightsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVMInsightsClientWithBaseURI creates an instance of the VMInsightsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewVMInsightsClientWithBaseURI(baseURI string, subscriptionID string) VMInsightsClient { + return VMInsightsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetOnboardingStatus retrieves the VM Insights onboarding status for the specified resource or resource scope. +// Parameters: +// resourceURI - the fully qualified Azure Resource manager identifier of the resource, or scope, whose status +// to retrieve. +func (client VMInsightsClient) GetOnboardingStatus(ctx context.Context, resourceURI string) (result VMInsightsOnboardingStatus, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VMInsightsClient.GetOnboardingStatus") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetOnboardingStatusPreparer(ctx, resourceURI) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", nil, "Failure preparing request") + return + } + + resp, err := client.GetOnboardingStatusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", resp, "Failure sending request") + return + } + + result, err = client.GetOnboardingStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", resp, "Failure responding to request") + return + } + + return +} + +// GetOnboardingStatusPreparer prepares the GetOnboardingStatus request. +func (client VMInsightsClient) GetOnboardingStatusPreparer(ctx context.Context, resourceURI string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2018-11-27-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetOnboardingStatusSender sends the GetOnboardingStatus request. The method will close the +// http.Response Body if it receives an error. +func (client VMInsightsClient) GetOnboardingStatusSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetOnboardingStatusResponder handles the response to the GetOnboardingStatus request. The method always +// closes the http.Response Body. +func (client VMInsightsClient) GetOnboardingStatusResponder(resp *http.Response) (result VMInsightsOnboardingStatus, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}