From a5a07d35b4f50312c4e46c8b822a5a28c03c4b9c Mon Sep 17 00:00:00 2001 From: ArcturusZhang Date: Tue, 6 Jul 2021 10:18:33 +0800 Subject: [PATCH 1/4] initial commit of monitor track 2 module --- sdk/monitor/armmonitor/CHANGELOG.md | 3 + sdk/monitor/armmonitor/README.md | 76 ++++++++++++++++++++++ sdk/monitor/armmonitor/_meta.json | 11 ++++ sdk/monitor/armmonitor/go_mod_tidy_hack.go | 12 ++++ 4 files changed, 102 insertions(+) create mode 100644 sdk/monitor/armmonitor/CHANGELOG.md create mode 100644 sdk/monitor/armmonitor/README.md create mode 100644 sdk/monitor/armmonitor/_meta.json create mode 100644 sdk/monitor/armmonitor/go_mod_tidy_hack.go diff --git a/sdk/monitor/armmonitor/CHANGELOG.md b/sdk/monitor/armmonitor/CHANGELOG.md new file mode 100644 index 000000000000..c7196df9ed8b --- /dev/null +++ b/sdk/monitor/armmonitor/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## v0.1.0 (released) diff --git a/sdk/monitor/armmonitor/README.md b/sdk/monitor/armmonitor/README.md new file mode 100644 index 000000000000..f11bb9e97fa0 --- /dev/null +++ b/sdk/monitor/armmonitor/README.md @@ -0,0 +1,76 @@ +# Azure Compute Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/compute/armcompute)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/compute/armcompute) + +The `armcompute` module provides operations for working with Azure compute. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/compute/armcompute) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Compute module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/compute/armcompute +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Compute. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Connecting to Azure Compute + +Once you have a credential, create a connection to the desired ARM endpoint. The `armcore` module provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := armcore.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, please see the documentation for `armcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore). + +## Clients + +Azure Compute modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your `armcore.Connection`. + +```go +client := armcompute.NewVirtualMachinesClient(con, "") +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Compute` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/monitor/armmonitor/_meta.json b/sdk/monitor/armmonitor/_meta.json new file mode 100644 index 000000000000..7fdf086f12ec --- /dev/null +++ b/sdk/monitor/armmonitor/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "f69f2e8053ac8ae352b11c33655234dea4cf4cfd", + "readme": "/_/azure-rest-api-specs/specification/monitor/resource-manager/readme.md", + "tag": "package-2021-03-01", + "use": "@autorest/go@4.0.0-preview.22", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@autorest/go@4.0.0-preview.22 --go --track2 --go-sdk-folder=/_/azure-sdk-for-go --file-prefix=\"zz_generated_\" --clear-output-folder=false /_/azure-rest-api-specs/specification/monitor/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --track2 --file-prefix=\"zz_generated_\" --clear-output-folder=false" + } +} \ No newline at end of file diff --git a/sdk/monitor/armmonitor/go_mod_tidy_hack.go b/sdk/monitor/armmonitor/go_mod_tidy_hack.go new file mode 100644 index 000000000000..f052e43aa44c --- /dev/null +++ b/sdk/monitor/armmonitor/go_mod_tidy_hack.go @@ -0,0 +1,12 @@ +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armmonitor + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" From ccee8df4ed4b7c4c6f6f4fa75dcd3bd44ef9ab60 Mon Sep 17 00:00:00 2001 From: ArcturusZhang Date: Tue, 6 Jul 2021 11:12:30 +0800 Subject: [PATCH 2/4] some attempt to generate monitor, not finished --- sdk/monitor/armmonitor/go.mod | 8 + .../zz_generated_actiongroups_client.go | 464 ++ .../zz_generated_activitylogalerts_client.go | 406 ++ .../zz_generated_activitylogs_client.go | 93 + .../zz_generated_alertruleincidents_client.go | 166 + .../zz_generated_alertrules_client.go | 406 ++ .../zz_generated_autoscalesettings_client.go | 406 ++ .../zz_generated_baselines_client.go | 111 + .../armmonitor/zz_generated_constants.go | 1194 ++++ ...enerated_datacollectionendpoints_client.go | 412 ++ ...d_datacollectionruleassociations_client.go | 335 + ...zz_generated_datacollectionrules_client.go | 412 ++ .../zz_generated_diagnosticsettings_client.go | 265 + ...rated_diagnosticsettingscategory_client.go | 150 + .../zz_generated_eventcategories_client.go | 82 + .../zz_generated_logprofiles_client.go | 324 + .../zz_generated_metricalerts_client.go | 406 ++ .../zz_generated_metricalertsstatus_client.go | 167 + .../zz_generated_metricdefinitions_client.go | 90 + .../zz_generated_metricnamespaces_client.go | 90 + .../armmonitor/zz_generated_metrics_client.go | 115 + sdk/monitor/armmonitor/zz_generated_models.go | 5551 +++++++++++++++++ .../zz_generated_operations_client.go | 80 + sdk/monitor/armmonitor/zz_generated_pagers.go | 698 +++ .../armmonitor/zz_generated_pollers.go | 139 + .../zz_generated_polymorphic_helpers.go | 248 + ...rated_privateendpointconnections_client.go | 380 ++ ...z_generated_privatelinkresources_client.go | 164 + ...rated_privatelinkscopedresources_client.go | 380 ++ ..._privatelinkscopeoperationstatus_client.go | 95 + .../zz_generated_privatelinkscopes_client.go | 448 ++ .../armmonitor/zz_generated_response_types.go | 449 ++ ...zz_generated_scheduledqueryrules_client.go | 412 ++ .../zz_generated_tenantactivitylogs_client.go | 90 + .../armmonitor/zz_generated_time_rfc3339.go | 57 + .../zz_generated_vminsights_client.go | 87 + 36 files changed, 15380 insertions(+) create mode 100644 sdk/monitor/armmonitor/go.mod create mode 100644 sdk/monitor/armmonitor/zz_generated_actiongroups_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_activitylogalerts_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_activitylogs_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_alertruleincidents_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_alertrules_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_autoscalesettings_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_baselines_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_constants.go create mode 100644 sdk/monitor/armmonitor/zz_generated_datacollectionendpoints_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_datacollectionruleassociations_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_datacollectionrules_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_diagnosticsettings_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_diagnosticsettingscategory_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_eventcategories_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_logprofiles_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_metricalerts_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_metricalertsstatus_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_metricdefinitions_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_metricnamespaces_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_metrics_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_models.go create mode 100644 sdk/monitor/armmonitor/zz_generated_operations_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_pagers.go create mode 100644 sdk/monitor/armmonitor/zz_generated_pollers.go create mode 100644 sdk/monitor/armmonitor/zz_generated_polymorphic_helpers.go create mode 100644 sdk/monitor/armmonitor/zz_generated_privateendpointconnections_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_privatelinkresources_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_privatelinkscopedresources_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_privatelinkscopeoperationstatus_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_privatelinkscopes_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_response_types.go create mode 100644 sdk/monitor/armmonitor/zz_generated_scheduledqueryrules_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_tenantactivitylogs_client.go create mode 100644 sdk/monitor/armmonitor/zz_generated_time_rfc3339.go create mode 100644 sdk/monitor/armmonitor/zz_generated_vminsights_client.go diff --git a/sdk/monitor/armmonitor/go.mod b/sdk/monitor/armmonitor/go.mod new file mode 100644 index 000000000000..9e74aed68f6d --- /dev/null +++ b/sdk/monitor/armmonitor/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/monitor/armmonitor + +go 1.13 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 +) diff --git a/sdk/monitor/armmonitor/zz_generated_actiongroups_client.go b/sdk/monitor/armmonitor/zz_generated_actiongroups_client.go new file mode 100644 index 000000000000..b792ed0c9b78 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_actiongroups_client.go @@ -0,0 +1,464 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// ActionGroupsClient contains the methods for the ActionGroups group. +// Don't use this type directly, use NewActionGroupsClient() instead. +type ActionGroupsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewActionGroupsClient creates a new instance of ActionGroupsClient with the specified values. +func NewActionGroupsClient(con *armcore.Connection, subscriptionID string) *ActionGroupsClient { + return &ActionGroupsClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create a new action group or update an existing one. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActionGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource, options *ActionGroupsCreateOrUpdateOptions) (ActionGroupResourceResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, actionGroupName, actionGroup, options) + if err != nil { + return ActionGroupResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ActionGroupResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return ActionGroupResourceResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ActionGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource, options *ActionGroupsCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if actionGroupName == "" { + return nil, errors.New("parameter actionGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{actionGroupName}", url.PathEscape(actionGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(actionGroup) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ActionGroupsClient) createOrUpdateHandleResponse(resp *azcore.Response) (ActionGroupResourceResponse, error) { + var val *ActionGroupResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ActionGroupResourceResponse{}, err + } + return ActionGroupResourceResponse{RawResponse: resp.Response, ActionGroupResource: val}, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ActionGroupsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Delete an action group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActionGroupsClient) Delete(ctx context.Context, resourceGroupName string, actionGroupName string, options *ActionGroupsDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, actionGroupName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp.Response, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ActionGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, actionGroupName string, options *ActionGroupsDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if actionGroupName == "" { + return nil, errors.New("parameter actionGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{actionGroupName}", url.PathEscape(actionGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ActionGroupsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// 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. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActionGroupsClient) EnableReceiver(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest, options *ActionGroupsEnableReceiverOptions) (*http.Response, error) { + req, err := client.enableReceiverCreateRequest(ctx, resourceGroupName, actionGroupName, enableRequest, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusConflict) { + return nil, client.enableReceiverHandleError(resp) + } + return resp.Response, nil +} + +// enableReceiverCreateRequest creates the EnableReceiver request. +func (client *ActionGroupsClient) enableReceiverCreateRequest(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest, options *ActionGroupsEnableReceiverOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if actionGroupName == "" { + return nil, errors.New("parameter actionGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{actionGroupName}", url.PathEscape(actionGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(enableRequest) +} + +// enableReceiverHandleError handles the EnableReceiver error response. +func (client *ActionGroupsClient) enableReceiverHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get an action group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActionGroupsClient) Get(ctx context.Context, resourceGroupName string, actionGroupName string, options *ActionGroupsGetOptions) (ActionGroupResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, actionGroupName, options) + if err != nil { + return ActionGroupResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ActionGroupResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ActionGroupResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ActionGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, actionGroupName string, options *ActionGroupsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if actionGroupName == "" { + return nil, errors.New("parameter actionGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{actionGroupName}", url.PathEscape(actionGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ActionGroupsClient) getHandleResponse(resp *azcore.Response) (ActionGroupResourceResponse, error) { + var val *ActionGroupResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ActionGroupResourceResponse{}, err + } + return ActionGroupResourceResponse{RawResponse: resp.Response, ActionGroupResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *ActionGroupsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - Get a list of all action groups in a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActionGroupsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *ActionGroupsListByResourceGroupOptions) (ActionGroupListResponse, error) { + req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return ActionGroupListResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ActionGroupListResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ActionGroupListResponse{}, client.listByResourceGroupHandleError(resp) + } + return client.listByResourceGroupHandleResponse(resp) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ActionGroupsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ActionGroupsListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ActionGroupsClient) listByResourceGroupHandleResponse(resp *azcore.Response) (ActionGroupListResponse, error) { + var val *ActionGroupList + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ActionGroupListResponse{}, err + } + return ActionGroupListResponse{RawResponse: resp.Response, ActionGroupList: val}, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *ActionGroupsClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListBySubscriptionID - Get a list of all action groups in a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActionGroupsClient) ListBySubscriptionID(ctx context.Context, options *ActionGroupsListBySubscriptionIDOptions) (ActionGroupListResponse, error) { + req, err := client.listBySubscriptionIDCreateRequest(ctx, options) + if err != nil { + return ActionGroupListResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ActionGroupListResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ActionGroupListResponse{}, client.listBySubscriptionIDHandleError(resp) + } + return client.listBySubscriptionIDHandleResponse(resp) +} + +// listBySubscriptionIDCreateRequest creates the ListBySubscriptionID request. +func (client *ActionGroupsClient) listBySubscriptionIDCreateRequest(ctx context.Context, options *ActionGroupsListBySubscriptionIDOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionIDHandleResponse handles the ListBySubscriptionID response. +func (client *ActionGroupsClient) listBySubscriptionIDHandleResponse(resp *azcore.Response) (ActionGroupListResponse, error) { + var val *ActionGroupList + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ActionGroupListResponse{}, err + } + return ActionGroupListResponse{RawResponse: resp.Response, ActionGroupList: val}, nil +} + +// listBySubscriptionIDHandleError handles the ListBySubscriptionID error response. +func (client *ActionGroupsClient) listBySubscriptionIDHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActionGroupsClient) Update(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch ActionGroupPatchBody, options *ActionGroupsUpdateOptions) (ActionGroupResourceResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, actionGroupName, actionGroupPatch, options) + if err != nil { + return ActionGroupResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ActionGroupResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ActionGroupResourceResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ActionGroupsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch ActionGroupPatchBody, options *ActionGroupsUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if actionGroupName == "" { + return nil, errors.New("parameter actionGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{actionGroupName}", url.PathEscape(actionGroupName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(actionGroupPatch) +} + +// updateHandleResponse handles the Update response. +func (client *ActionGroupsClient) updateHandleResponse(resp *azcore.Response) (ActionGroupResourceResponse, error) { + var val *ActionGroupResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ActionGroupResourceResponse{}, err + } + return ActionGroupResourceResponse{RawResponse: resp.Response, ActionGroupResource: val}, nil +} + +// updateHandleError handles the Update error response. +func (client *ActionGroupsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_activitylogalerts_client.go b/sdk/monitor/armmonitor/zz_generated_activitylogalerts_client.go new file mode 100644 index 000000000000..3f583744b405 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_activitylogalerts_client.go @@ -0,0 +1,406 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// ActivityLogAlertsClient contains the methods for the ActivityLogAlerts group. +// Don't use this type directly, use NewActivityLogAlertsClient() instead. +type ActivityLogAlertsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewActivityLogAlertsClient creates a new instance of ActivityLogAlertsClient with the specified values. +func NewActivityLogAlertsClient(con *armcore.Connection, subscriptionID string) *ActivityLogAlertsClient { + return &ActivityLogAlertsClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create a new activity log alert or update an existing one. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActivityLogAlertsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlert ActivityLogAlertResource, options *ActivityLogAlertsCreateOrUpdateOptions) (ActivityLogAlertResourceResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, activityLogAlertName, activityLogAlert, options) + if err != nil { + return ActivityLogAlertResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ActivityLogAlertResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return ActivityLogAlertResourceResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ActivityLogAlertsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlert ActivityLogAlertResource, options *ActivityLogAlertsCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if activityLogAlertName == "" { + return nil, errors.New("parameter activityLogAlertName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{activityLogAlertName}", url.PathEscape(activityLogAlertName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(activityLogAlert) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ActivityLogAlertsClient) createOrUpdateHandleResponse(resp *azcore.Response) (ActivityLogAlertResourceResponse, error) { + var val *ActivityLogAlertResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ActivityLogAlertResourceResponse{}, err + } + return ActivityLogAlertResourceResponse{RawResponse: resp.Response, ActivityLogAlertResource: val}, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ActivityLogAlertsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Delete an activity log alert. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActivityLogAlertsClient) Delete(ctx context.Context, resourceGroupName string, activityLogAlertName string, options *ActivityLogAlertsDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, activityLogAlertName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp.Response, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ActivityLogAlertsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, activityLogAlertName string, options *ActivityLogAlertsDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if activityLogAlertName == "" { + return nil, errors.New("parameter activityLogAlertName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{activityLogAlertName}", url.PathEscape(activityLogAlertName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ActivityLogAlertsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get an activity log alert. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActivityLogAlertsClient) Get(ctx context.Context, resourceGroupName string, activityLogAlertName string, options *ActivityLogAlertsGetOptions) (ActivityLogAlertResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, activityLogAlertName, options) + if err != nil { + return ActivityLogAlertResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ActivityLogAlertResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ActivityLogAlertResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ActivityLogAlertsClient) getCreateRequest(ctx context.Context, resourceGroupName string, activityLogAlertName string, options *ActivityLogAlertsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if activityLogAlertName == "" { + return nil, errors.New("parameter activityLogAlertName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{activityLogAlertName}", url.PathEscape(activityLogAlertName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ActivityLogAlertsClient) getHandleResponse(resp *azcore.Response) (ActivityLogAlertResourceResponse, error) { + var val *ActivityLogAlertResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ActivityLogAlertResourceResponse{}, err + } + return ActivityLogAlertResourceResponse{RawResponse: resp.Response, ActivityLogAlertResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *ActivityLogAlertsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - Get a list of all activity log alerts in a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActivityLogAlertsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *ActivityLogAlertsListByResourceGroupOptions) (ActivityLogAlertListResponse, error) { + req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return ActivityLogAlertListResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ActivityLogAlertListResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ActivityLogAlertListResponse{}, client.listByResourceGroupHandleError(resp) + } + return client.listByResourceGroupHandleResponse(resp) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ActivityLogAlertsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ActivityLogAlertsListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ActivityLogAlertsClient) listByResourceGroupHandleResponse(resp *azcore.Response) (ActivityLogAlertListResponse, error) { + var val *ActivityLogAlertList + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ActivityLogAlertListResponse{}, err + } + return ActivityLogAlertListResponse{RawResponse: resp.Response, ActivityLogAlertList: val}, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *ActivityLogAlertsClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListBySubscriptionID - Get a list of all activity log alerts in a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActivityLogAlertsClient) ListBySubscriptionID(ctx context.Context, options *ActivityLogAlertsListBySubscriptionIDOptions) (ActivityLogAlertListResponse, error) { + req, err := client.listBySubscriptionIDCreateRequest(ctx, options) + if err != nil { + return ActivityLogAlertListResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ActivityLogAlertListResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ActivityLogAlertListResponse{}, client.listBySubscriptionIDHandleError(resp) + } + return client.listBySubscriptionIDHandleResponse(resp) +} + +// listBySubscriptionIDCreateRequest creates the ListBySubscriptionID request. +func (client *ActivityLogAlertsClient) listBySubscriptionIDCreateRequest(ctx context.Context, options *ActivityLogAlertsListBySubscriptionIDOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionIDHandleResponse handles the ListBySubscriptionID response. +func (client *ActivityLogAlertsClient) listBySubscriptionIDHandleResponse(resp *azcore.Response) (ActivityLogAlertListResponse, error) { + var val *ActivityLogAlertList + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ActivityLogAlertListResponse{}, err + } + return ActivityLogAlertListResponse{RawResponse: resp.Response, ActivityLogAlertList: val}, nil +} + +// listBySubscriptionIDHandleError handles the ListBySubscriptionID error response. +func (client *ActivityLogAlertsClient) listBySubscriptionIDHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActivityLogAlertsClient) Update(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertPatch ActivityLogAlertPatchBody, options *ActivityLogAlertsUpdateOptions) (ActivityLogAlertResourceResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, activityLogAlertName, activityLogAlertPatch, options) + if err != nil { + return ActivityLogAlertResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ActivityLogAlertResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ActivityLogAlertResourceResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ActivityLogAlertsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertPatch ActivityLogAlertPatchBody, options *ActivityLogAlertsUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if activityLogAlertName == "" { + return nil, errors.New("parameter activityLogAlertName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{activityLogAlertName}", url.PathEscape(activityLogAlertName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(activityLogAlertPatch) +} + +// updateHandleResponse handles the Update response. +func (client *ActivityLogAlertsClient) updateHandleResponse(resp *azcore.Response) (ActivityLogAlertResourceResponse, error) { + var val *ActivityLogAlertResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ActivityLogAlertResourceResponse{}, err + } + return ActivityLogAlertResourceResponse{RawResponse: resp.Response, ActivityLogAlertResource: val}, nil +} + +// updateHandleError handles the Update error response. +func (client *ActivityLogAlertsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_activitylogs_client.go b/sdk/monitor/armmonitor/zz_generated_activitylogs_client.go new file mode 100644 index 000000000000..6c3cd42137f6 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_activitylogs_client.go @@ -0,0 +1,93 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// ActivityLogsClient contains the methods for the ActivityLogs group. +// Don't use this type directly, use NewActivityLogsClient() instead. +type ActivityLogsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewActivityLogsClient creates a new instance of ActivityLogsClient with the specified values. +func NewActivityLogsClient(con *armcore.Connection, subscriptionID string) *ActivityLogsClient { + return &ActivityLogsClient{con: con, subscriptionID: subscriptionID} +} + +// List - Provides the list of records from the activity logs. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ActivityLogsClient) List(filter string, options *ActivityLogsListOptions) EventDataCollectionPager { + return &eventDataCollectionPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, filter, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp EventDataCollectionResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.EventDataCollection.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *ActivityLogsClient) listCreateRequest(ctx context.Context, filter string, options *ActivityLogsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2015-04-01") + reqQP.Set("$filter", filter) + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ActivityLogsClient) listHandleResponse(resp *azcore.Response) (EventDataCollectionResponse, error) { + var val *EventDataCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return EventDataCollectionResponse{}, err + } + return EventDataCollectionResponse{RawResponse: resp.Response, EventDataCollection: val}, nil +} + +// listHandleError handles the List error response. +func (client *ActivityLogsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_alertruleincidents_client.go b/sdk/monitor/armmonitor/zz_generated_alertruleincidents_client.go new file mode 100644 index 000000000000..063739b382b0 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_alertruleincidents_client.go @@ -0,0 +1,166 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// AlertRuleIncidentsClient contains the methods for the AlertRuleIncidents group. +// Don't use this type directly, use NewAlertRuleIncidentsClient() instead. +type AlertRuleIncidentsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAlertRuleIncidentsClient creates a new instance of AlertRuleIncidentsClient with the specified values. +func NewAlertRuleIncidentsClient(con *armcore.Connection, subscriptionID string) *AlertRuleIncidentsClient { + return &AlertRuleIncidentsClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Gets an incident associated to an alert rule +// If the operation fails it returns the *ErrorResponse error type. +func (client *AlertRuleIncidentsClient) Get(ctx context.Context, resourceGroupName string, ruleName string, incidentName string, options *AlertRuleIncidentsGetOptions) (IncidentResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, ruleName, incidentName, options) + if err != nil { + return IncidentResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IncidentResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return IncidentResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AlertRuleIncidentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, incidentName string, options *AlertRuleIncidentsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + if incidentName == "" { + return nil, errors.New("parameter incidentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{incidentName}", url.PathEscape(incidentName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AlertRuleIncidentsClient) getHandleResponse(resp *azcore.Response) (IncidentResponse, error) { + var val *Incident + if err := resp.UnmarshalAsJSON(&val); err != nil { + return IncidentResponse{}, err + } + return IncidentResponse{RawResponse: resp.Response, Incident: val}, nil +} + +// getHandleError handles the Get error response. +func (client *AlertRuleIncidentsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByAlertRule - Gets a list of incidents associated to an alert rule +// If the operation fails it returns a generic error. +func (client *AlertRuleIncidentsClient) ListByAlertRule(ctx context.Context, resourceGroupName string, ruleName string, options *AlertRuleIncidentsListByAlertRuleOptions) (IncidentListResultResponse, error) { + req, err := client.listByAlertRuleCreateRequest(ctx, resourceGroupName, ruleName, options) + if err != nil { + return IncidentListResultResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IncidentListResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return IncidentListResultResponse{}, client.listByAlertRuleHandleError(resp) + } + return client.listByAlertRuleHandleResponse(resp) +} + +// listByAlertRuleCreateRequest creates the ListByAlertRule request. +func (client *AlertRuleIncidentsClient) listByAlertRuleCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, options *AlertRuleIncidentsListByAlertRuleOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByAlertRuleHandleResponse handles the ListByAlertRule response. +func (client *AlertRuleIncidentsClient) listByAlertRuleHandleResponse(resp *azcore.Response) (IncidentListResultResponse, error) { + var val *IncidentListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return IncidentListResultResponse{}, err + } + return IncidentListResultResponse{RawResponse: resp.Response, IncidentListResult: val}, nil +} + +// listByAlertRuleHandleError handles the ListByAlertRule error response. +func (client *AlertRuleIncidentsClient) listByAlertRuleHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_alertrules_client.go b/sdk/monitor/armmonitor/zz_generated_alertrules_client.go new file mode 100644 index 000000000000..c9b1b385a883 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_alertrules_client.go @@ -0,0 +1,406 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// AlertRulesClient contains the methods for the AlertRules group. +// Don't use this type directly, use NewAlertRulesClient() instead. +type AlertRulesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAlertRulesClient creates a new instance of AlertRulesClient with the specified values. +func NewAlertRulesClient(con *armcore.Connection, subscriptionID string) *AlertRulesClient { + return &AlertRulesClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates a classic metric alert rule. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AlertRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters AlertRuleResource, options *AlertRulesCreateOrUpdateOptions) (AlertRuleResourceResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, ruleName, parameters, options) + if err != nil { + return AlertRuleResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AlertRuleResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return AlertRuleResourceResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AlertRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, parameters AlertRuleResource, options *AlertRulesCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *AlertRulesClient) createOrUpdateHandleResponse(resp *azcore.Response) (AlertRuleResourceResponse, error) { + var val *AlertRuleResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AlertRuleResourceResponse{}, err + } + return AlertRuleResourceResponse{RawResponse: resp.Response, AlertRuleResource: val}, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *AlertRulesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes a classic metric alert rule +// If the operation fails it returns the *ErrorResponse error type. +func (client *AlertRulesClient) Delete(ctx context.Context, resourceGroupName string, ruleName string, options *AlertRulesDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, ruleName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp.Response, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AlertRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, options *AlertRulesDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *AlertRulesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets a classic metric alert rule +// If the operation fails it returns the *ErrorResponse error type. +func (client *AlertRulesClient) Get(ctx context.Context, resourceGroupName string, ruleName string, options *AlertRulesGetOptions) (AlertRuleResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, ruleName, options) + if err != nil { + return AlertRuleResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AlertRuleResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AlertRuleResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AlertRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, options *AlertRulesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AlertRulesClient) getHandleResponse(resp *azcore.Response) (AlertRuleResourceResponse, error) { + var val *AlertRuleResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AlertRuleResourceResponse{}, err + } + return AlertRuleResourceResponse{RawResponse: resp.Response, AlertRuleResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *AlertRulesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - List the classic metric alert rules within a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AlertRulesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *AlertRulesListByResourceGroupOptions) (AlertRuleResourceCollectionResponse, error) { + req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return AlertRuleResourceCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AlertRuleResourceCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AlertRuleResourceCollectionResponse{}, client.listByResourceGroupHandleError(resp) + } + return client.listByResourceGroupHandleResponse(resp) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *AlertRulesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AlertRulesListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *AlertRulesClient) listByResourceGroupHandleResponse(resp *azcore.Response) (AlertRuleResourceCollectionResponse, error) { + var val *AlertRuleResourceCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AlertRuleResourceCollectionResponse{}, err + } + return AlertRuleResourceCollectionResponse{RawResponse: resp.Response, AlertRuleResourceCollection: val}, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *AlertRulesClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListBySubscription - List the classic metric alert rules within a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AlertRulesClient) ListBySubscription(ctx context.Context, options *AlertRulesListBySubscriptionOptions) (AlertRuleResourceCollectionResponse, error) { + req, err := client.listBySubscriptionCreateRequest(ctx, options) + if err != nil { + return AlertRuleResourceCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AlertRuleResourceCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AlertRuleResourceCollectionResponse{}, client.listBySubscriptionHandleError(resp) + } + return client.listBySubscriptionHandleResponse(resp) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *AlertRulesClient) listBySubscriptionCreateRequest(ctx context.Context, options *AlertRulesListBySubscriptionOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *AlertRulesClient) listBySubscriptionHandleResponse(resp *azcore.Response) (AlertRuleResourceCollectionResponse, error) { + var val *AlertRuleResourceCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AlertRuleResourceCollectionResponse{}, err + } + return AlertRuleResourceCollectionResponse{RawResponse: resp.Response, AlertRuleResourceCollection: val}, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *AlertRulesClient) listBySubscriptionHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AlertRulesClient) Update(ctx context.Context, resourceGroupName string, ruleName string, alertRulesResource AlertRuleResourcePatch, options *AlertRulesUpdateOptions) (AlertRuleResourceResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, ruleName, alertRulesResource, options) + if err != nil { + return AlertRuleResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AlertRuleResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return AlertRuleResourceResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *AlertRulesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, alertRulesResource AlertRuleResourcePatch, options *AlertRulesUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(alertRulesResource) +} + +// updateHandleResponse handles the Update response. +func (client *AlertRulesClient) updateHandleResponse(resp *azcore.Response) (AlertRuleResourceResponse, error) { + var val *AlertRuleResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AlertRuleResourceResponse{}, err + } + return AlertRuleResourceResponse{RawResponse: resp.Response, AlertRuleResource: val}, nil +} + +// updateHandleError handles the Update error response. +func (client *AlertRulesClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_autoscalesettings_client.go b/sdk/monitor/armmonitor/zz_generated_autoscalesettings_client.go new file mode 100644 index 000000000000..4ab00a037747 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_autoscalesettings_client.go @@ -0,0 +1,406 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// AutoscaleSettingsClient contains the methods for the AutoscaleSettings group. +// Don't use this type directly, use NewAutoscaleSettingsClient() instead. +type AutoscaleSettingsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAutoscaleSettingsClient creates a new instance of AutoscaleSettingsClient with the specified values. +func NewAutoscaleSettingsClient(con *armcore.Connection, subscriptionID string) *AutoscaleSettingsClient { + return &AutoscaleSettingsClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates an autoscale setting. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AutoscaleSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource, options *AutoscaleSettingsCreateOrUpdateOptions) (AutoscaleSettingResourceResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, autoscaleSettingName, parameters, options) + if err != nil { + return AutoscaleSettingResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AutoscaleSettingResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return AutoscaleSettingResourceResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AutoscaleSettingsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource, options *AutoscaleSettingsCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if autoscaleSettingName == "" { + return nil, errors.New("parameter autoscaleSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{autoscaleSettingName}", url.PathEscape(autoscaleSettingName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2015-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *AutoscaleSettingsClient) createOrUpdateHandleResponse(resp *azcore.Response) (AutoscaleSettingResourceResponse, error) { + var val *AutoscaleSettingResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AutoscaleSettingResourceResponse{}, err + } + return AutoscaleSettingResourceResponse{RawResponse: resp.Response, AutoscaleSettingResource: val}, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *AutoscaleSettingsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes and autoscale setting +// If the operation fails it returns the *ErrorResponse error type. +func (client *AutoscaleSettingsClient) Delete(ctx context.Context, resourceGroupName string, autoscaleSettingName string, options *AutoscaleSettingsDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, autoscaleSettingName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp.Response, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AutoscaleSettingsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, autoscaleSettingName string, options *AutoscaleSettingsDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if autoscaleSettingName == "" { + return nil, errors.New("parameter autoscaleSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{autoscaleSettingName}", url.PathEscape(autoscaleSettingName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2015-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *AutoscaleSettingsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets an autoscale setting +// If the operation fails it returns the *ErrorResponse error type. +func (client *AutoscaleSettingsClient) Get(ctx context.Context, resourceGroupName string, autoscaleSettingName string, options *AutoscaleSettingsGetOptions) (AutoscaleSettingResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, autoscaleSettingName, options) + if err != nil { + return AutoscaleSettingResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AutoscaleSettingResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AutoscaleSettingResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AutoscaleSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, autoscaleSettingName string, options *AutoscaleSettingsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if autoscaleSettingName == "" { + return nil, errors.New("parameter autoscaleSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{autoscaleSettingName}", url.PathEscape(autoscaleSettingName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2015-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AutoscaleSettingsClient) getHandleResponse(resp *azcore.Response) (AutoscaleSettingResourceResponse, error) { + var val *AutoscaleSettingResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AutoscaleSettingResourceResponse{}, err + } + return AutoscaleSettingResourceResponse{RawResponse: resp.Response, AutoscaleSettingResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *AutoscaleSettingsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - Lists the autoscale settings for a resource group +// If the operation fails it returns the *ErrorResponse error type. +func (client *AutoscaleSettingsClient) ListByResourceGroup(resourceGroupName string, options *AutoscaleSettingsListByResourceGroupOptions) AutoscaleSettingResourceCollectionPager { + return &autoscaleSettingResourceCollectionPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + responder: client.listByResourceGroupHandleResponse, + errorer: client.listByResourceGroupHandleError, + advancer: func(ctx context.Context, resp AutoscaleSettingResourceCollectionResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.AutoscaleSettingResourceCollection.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *AutoscaleSettingsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AutoscaleSettingsListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2015-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *AutoscaleSettingsClient) listByResourceGroupHandleResponse(resp *azcore.Response) (AutoscaleSettingResourceCollectionResponse, error) { + var val *AutoscaleSettingResourceCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AutoscaleSettingResourceCollectionResponse{}, err + } + return AutoscaleSettingResourceCollectionResponse{RawResponse: resp.Response, AutoscaleSettingResourceCollection: val}, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *AutoscaleSettingsClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListBySubscription - Lists the autoscale settings for a subscription +// If the operation fails it returns the *ErrorResponse error type. +func (client *AutoscaleSettingsClient) ListBySubscription(options *AutoscaleSettingsListBySubscriptionOptions) AutoscaleSettingResourceCollectionPager { + return &autoscaleSettingResourceCollectionPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + responder: client.listBySubscriptionHandleResponse, + errorer: client.listBySubscriptionHandleError, + advancer: func(ctx context.Context, resp AutoscaleSettingResourceCollectionResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.AutoscaleSettingResourceCollection.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *AutoscaleSettingsClient) listBySubscriptionCreateRequest(ctx context.Context, options *AutoscaleSettingsListBySubscriptionOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2015-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *AutoscaleSettingsClient) listBySubscriptionHandleResponse(resp *azcore.Response) (AutoscaleSettingResourceCollectionResponse, error) { + var val *AutoscaleSettingResourceCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AutoscaleSettingResourceCollectionResponse{}, err + } + return AutoscaleSettingResourceCollectionResponse{RawResponse: resp.Response, AutoscaleSettingResourceCollection: val}, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *AutoscaleSettingsClient) listBySubscriptionHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AutoscaleSettingsClient) Update(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource AutoscaleSettingResourcePatch, options *AutoscaleSettingsUpdateOptions) (AutoscaleSettingResourceResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, autoscaleSettingName, autoscaleSettingResource, options) + if err != nil { + return AutoscaleSettingResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AutoscaleSettingResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AutoscaleSettingResourceResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *AutoscaleSettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource AutoscaleSettingResourcePatch, options *AutoscaleSettingsUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if autoscaleSettingName == "" { + return nil, errors.New("parameter autoscaleSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{autoscaleSettingName}", url.PathEscape(autoscaleSettingName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2015-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(autoscaleSettingResource) +} + +// updateHandleResponse handles the Update response. +func (client *AutoscaleSettingsClient) updateHandleResponse(resp *azcore.Response) (AutoscaleSettingResourceResponse, error) { + var val *AutoscaleSettingResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AutoscaleSettingResourceResponse{}, err + } + return AutoscaleSettingResourceResponse{RawResponse: resp.Response, AutoscaleSettingResource: val}, nil +} + +// updateHandleError handles the Update error response. +func (client *AutoscaleSettingsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_baselines_client.go b/sdk/monitor/armmonitor/zz_generated_baselines_client.go new file mode 100644 index 000000000000..612918de490e --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_baselines_client.go @@ -0,0 +1,111 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "strings" +) + +// BaselinesClient contains the methods for the Baselines group. +// Don't use this type directly, use NewBaselinesClient() instead. +type BaselinesClient struct { + con *armcore.Connection +} + +// NewBaselinesClient creates a new instance of BaselinesClient with the specified values. +func NewBaselinesClient(con *armcore.Connection) *BaselinesClient { + return &BaselinesClient{con: con} +} + +// List - Lists the metric baseline values for a resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *BaselinesClient) List(ctx context.Context, resourceURI string, options *BaselinesListOptions) (MetricBaselinesResponseResponse, error) { + req, err := client.listCreateRequest(ctx, resourceURI, options) + if err != nil { + return MetricBaselinesResponseResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return MetricBaselinesResponseResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return MetricBaselinesResponseResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *BaselinesClient) listCreateRequest(ctx context.Context, resourceURI string, options *BaselinesListOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/metricBaselines" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Metricnames != nil { + reqQP.Set("metricnames", *options.Metricnames) + } + if options != nil && options.Metricnamespace != nil { + reqQP.Set("metricnamespace", *options.Metricnamespace) + } + if options != nil && options.Timespan != nil { + reqQP.Set("timespan", *options.Timespan) + } + if options != nil && options.Interval != nil { + reqQP.Set("interval", *options.Interval) + } + if options != nil && options.Aggregation != nil { + reqQP.Set("aggregation", *options.Aggregation) + } + if options != nil && options.Sensitivities != nil { + reqQP.Set("sensitivities", *options.Sensitivities) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.ResultType != nil { + reqQP.Set("resultType", string(*options.ResultType)) + } + reqQP.Set("api-version", "2019-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *BaselinesClient) listHandleResponse(resp *azcore.Response) (MetricBaselinesResponseResponse, error) { + var val *MetricBaselinesResponse + if err := resp.UnmarshalAsJSON(&val); err != nil { + return MetricBaselinesResponseResponse{}, err + } + return MetricBaselinesResponseResponse{RawResponse: resp.Response, MetricBaselinesResponse: val}, nil +} + +// listHandleError handles the List error response. +func (client *BaselinesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_constants.go b/sdk/monitor/armmonitor/zz_generated_constants.go new file mode 100644 index 000000000000..476d16e2d15d --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_constants.go @@ -0,0 +1,1194 @@ +// +build go1.13 + +// 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. + +package armmonitor + +const telemetryInfo = "azsdk-go-armmonitor/" + +// AggregationType - the aggregation type of the metric. +type AggregationType string + +const ( + AggregationTypeNone AggregationType = "None" + AggregationTypeAverage AggregationType = "Average" + AggregationTypeCount AggregationType = "Count" + AggregationTypeMinimum AggregationType = "Minimum" + AggregationTypeMaximum AggregationType = "Maximum" + AggregationTypeTotal AggregationType = "Total" +) + +// PossibleAggregationTypeValues returns the possible values for the AggregationType const type. +func PossibleAggregationTypeValues() []AggregationType { + return []AggregationType{ + AggregationTypeNone, + AggregationTypeAverage, + AggregationTypeCount, + AggregationTypeMinimum, + AggregationTypeMaximum, + AggregationTypeTotal, + } +} + +// ToPtr returns a *AggregationType pointing to the current value. +func (c AggregationType) ToPtr() *AggregationType { + return &c +} + +// AggregationTypeEnum - the criteria time aggregation types. +type AggregationTypeEnum string + +const ( + AggregationTypeEnumAverage AggregationTypeEnum = "Average" + AggregationTypeEnumCount AggregationTypeEnum = "Count" + AggregationTypeEnumMaximum AggregationTypeEnum = "Maximum" + AggregationTypeEnumMinimum AggregationTypeEnum = "Minimum" + AggregationTypeEnumTotal AggregationTypeEnum = "Total" +) + +// PossibleAggregationTypeEnumValues returns the possible values for the AggregationTypeEnum const type. +func PossibleAggregationTypeEnumValues() []AggregationTypeEnum { + return []AggregationTypeEnum{ + AggregationTypeEnumAverage, + AggregationTypeEnumCount, + AggregationTypeEnumMaximum, + AggregationTypeEnumMinimum, + AggregationTypeEnumTotal, + } +} + +// ToPtr returns a *AggregationTypeEnum pointing to the current value. +func (c AggregationTypeEnum) ToPtr() *AggregationTypeEnum { + return &c +} + +// AlertSeverity - Severity Level of Alert +type AlertSeverity string + +const ( + AlertSeverityFour AlertSeverity = "4" + AlertSeverityOne AlertSeverity = "1" + AlertSeverityThree AlertSeverity = "3" + AlertSeverityTwo AlertSeverity = "2" + AlertSeverityZero AlertSeverity = "0" +) + +// PossibleAlertSeverityValues returns the possible values for the AlertSeverity const type. +func PossibleAlertSeverityValues() []AlertSeverity { + return []AlertSeverity{ + AlertSeverityFour, + AlertSeverityOne, + AlertSeverityThree, + AlertSeverityTwo, + AlertSeverityZero, + } +} + +// ToPtr returns a *AlertSeverity pointing to the current value. +func (c AlertSeverity) ToPtr() *AlertSeverity { + return &c +} + +// BaselineSensitivity - the sensitivity of the baseline. +type BaselineSensitivity string + +const ( + BaselineSensitivityHigh BaselineSensitivity = "High" + BaselineSensitivityLow BaselineSensitivity = "Low" + BaselineSensitivityMedium BaselineSensitivity = "Medium" +) + +// PossibleBaselineSensitivityValues returns the possible values for the BaselineSensitivity const type. +func PossibleBaselineSensitivityValues() []BaselineSensitivity { + return []BaselineSensitivity{ + BaselineSensitivityHigh, + BaselineSensitivityLow, + BaselineSensitivityMedium, + } +} + +// ToPtr returns a *BaselineSensitivity pointing to the current value. +func (c BaselineSensitivity) ToPtr() *BaselineSensitivity { + return &c +} + +// CategoryType - The type of the diagnostic settings category. +type CategoryType string + +const ( + CategoryTypeMetrics CategoryType = "Metrics" + CategoryTypeLogs CategoryType = "Logs" +) + +// PossibleCategoryTypeValues returns the possible values for the CategoryType const type. +func PossibleCategoryTypeValues() []CategoryType { + return []CategoryType{ + CategoryTypeMetrics, + CategoryTypeLogs, + } +} + +// ToPtr returns a *CategoryType pointing to the current value. +func (c CategoryType) ToPtr() *CategoryType { + return &c +} + +// ComparisonOperationType - the operator that is used to compare the metric data and the threshold. +type ComparisonOperationType string + +const ( + ComparisonOperationTypeEquals ComparisonOperationType = "Equals" + ComparisonOperationTypeNotEquals ComparisonOperationType = "NotEquals" + ComparisonOperationTypeGreaterThan ComparisonOperationType = "GreaterThan" + ComparisonOperationTypeGreaterThanOrEqual ComparisonOperationType = "GreaterThanOrEqual" + ComparisonOperationTypeLessThan ComparisonOperationType = "LessThan" + ComparisonOperationTypeLessThanOrEqual ComparisonOperationType = "LessThanOrEqual" +) + +// PossibleComparisonOperationTypeValues returns the possible values for the ComparisonOperationType const type. +func PossibleComparisonOperationTypeValues() []ComparisonOperationType { + return []ComparisonOperationType{ + ComparisonOperationTypeEquals, + ComparisonOperationTypeNotEquals, + ComparisonOperationTypeGreaterThan, + ComparisonOperationTypeGreaterThanOrEqual, + ComparisonOperationTypeLessThan, + ComparisonOperationTypeLessThanOrEqual, + } +} + +// ToPtr returns a *ComparisonOperationType pointing to the current value. +func (c ComparisonOperationType) ToPtr() *ComparisonOperationType { + return &c +} + +// ConditionOperator - Operators allowed in the rule condition. +type ConditionOperator string + +const ( + ConditionOperatorGreaterThan ConditionOperator = "GreaterThan" + ConditionOperatorGreaterThanOrEqual ConditionOperator = "GreaterThanOrEqual" + ConditionOperatorLessThan ConditionOperator = "LessThan" + ConditionOperatorLessThanOrEqual ConditionOperator = "LessThanOrEqual" +) + +// PossibleConditionOperatorValues returns the possible values for the ConditionOperator const type. +func PossibleConditionOperatorValues() []ConditionOperator { + return []ConditionOperator{ + ConditionOperatorGreaterThan, + ConditionOperatorGreaterThanOrEqual, + ConditionOperatorLessThan, + ConditionOperatorLessThanOrEqual, + } +} + +// ToPtr returns a *ConditionOperator pointing to the current value. +func (c ConditionOperator) ToPtr() *ConditionOperator { + return &c +} + +// ConditionalOperator - Result Condition Evaluation criteria. Supported Values - 'GreaterThan' or 'LessThan' or 'Equal'. +type ConditionalOperator string + +const ( + ConditionalOperatorEqual ConditionalOperator = "Equal" + ConditionalOperatorGreaterThan ConditionalOperator = "GreaterThan" + ConditionalOperatorGreaterThanOrEqual ConditionalOperator = "GreaterThanOrEqual" + ConditionalOperatorLessThan ConditionalOperator = "LessThan" + ConditionalOperatorLessThanOrEqual ConditionalOperator = "LessThanOrEqual" +) + +// PossibleConditionalOperatorValues returns the possible values for the ConditionalOperator const type. +func PossibleConditionalOperatorValues() []ConditionalOperator { + return []ConditionalOperator{ + ConditionalOperatorEqual, + ConditionalOperatorGreaterThan, + ConditionalOperatorGreaterThanOrEqual, + ConditionalOperatorLessThan, + ConditionalOperatorLessThanOrEqual, + } +} + +// ToPtr returns a *ConditionalOperator pointing to the current value. +func (c ConditionalOperator) ToPtr() *ConditionalOperator { + return &c +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// CriterionType - Specifies the type of threshold criteria +type CriterionType string + +const ( + CriterionTypeDynamicThresholdCriterion CriterionType = "DynamicThresholdCriterion" + CriterionTypeStaticThresholdCriterion CriterionType = "StaticThresholdCriterion" +) + +// PossibleCriterionTypeValues returns the possible values for the CriterionType const type. +func PossibleCriterionTypeValues() []CriterionType { + return []CriterionType{ + CriterionTypeDynamicThresholdCriterion, + CriterionTypeStaticThresholdCriterion, + } +} + +// ToPtr returns a *CriterionType pointing to the current value. +func (c CriterionType) ToPtr() *CriterionType { + return &c +} + +// 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. +type DataStatus string + +const ( + DataStatusNotPresent DataStatus = "notPresent" + DataStatusPresent DataStatus = "present" +) + +// PossibleDataStatusValues returns the possible values for the DataStatus const type. +func PossibleDataStatusValues() []DataStatus { + return []DataStatus{ + DataStatusNotPresent, + DataStatusPresent, + } +} + +// ToPtr returns a *DataStatus pointing to the current value. +func (c DataStatus) ToPtr() *DataStatus { + return &c +} + +// DynamicThresholdOperator - The operator used to compare the metric value against the threshold. +type DynamicThresholdOperator string + +const ( + DynamicThresholdOperatorGreaterOrLessThan DynamicThresholdOperator = "GreaterOrLessThan" + DynamicThresholdOperatorGreaterThan DynamicThresholdOperator = "GreaterThan" + DynamicThresholdOperatorLessThan DynamicThresholdOperator = "LessThan" +) + +// PossibleDynamicThresholdOperatorValues returns the possible values for the DynamicThresholdOperator const type. +func PossibleDynamicThresholdOperatorValues() []DynamicThresholdOperator { + return []DynamicThresholdOperator{ + DynamicThresholdOperatorGreaterOrLessThan, + DynamicThresholdOperatorGreaterThan, + DynamicThresholdOperatorLessThan, + } +} + +// ToPtr returns a *DynamicThresholdOperator pointing to the current value. +func (c DynamicThresholdOperator) ToPtr() *DynamicThresholdOperator { + return &c +} + +// DynamicThresholdSensitivity - The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series +// pattern. +type DynamicThresholdSensitivity string + +const ( + DynamicThresholdSensitivityHigh DynamicThresholdSensitivity = "High" + DynamicThresholdSensitivityLow DynamicThresholdSensitivity = "Low" + DynamicThresholdSensitivityMedium DynamicThresholdSensitivity = "Medium" +) + +// PossibleDynamicThresholdSensitivityValues returns the possible values for the DynamicThresholdSensitivity const type. +func PossibleDynamicThresholdSensitivityValues() []DynamicThresholdSensitivity { + return []DynamicThresholdSensitivity{ + DynamicThresholdSensitivityHigh, + DynamicThresholdSensitivityLow, + DynamicThresholdSensitivityMedium, + } +} + +// ToPtr returns a *DynamicThresholdSensitivity pointing to the current value. +func (c DynamicThresholdSensitivity) ToPtr() *DynamicThresholdSensitivity { + return &c +} + +// Enabled - The flag which indicates whether the Log Search rule is enabled. Value should be true or false +type Enabled string + +const ( + EnabledFalse Enabled = "false" + EnabledTrue Enabled = "true" +) + +// PossibleEnabledValues returns the possible values for the Enabled const type. +func PossibleEnabledValues() []Enabled { + return []Enabled{ + EnabledFalse, + EnabledTrue, + } +} + +// ToPtr returns a *Enabled pointing to the current value. +func (c Enabled) ToPtr() *Enabled { + return &c +} + +// EventLevel - the event level +type EventLevel string + +const ( + EventLevelCritical EventLevel = "Critical" + EventLevelError EventLevel = "Error" + EventLevelWarning EventLevel = "Warning" + EventLevelInformational EventLevel = "Informational" + EventLevelVerbose EventLevel = "Verbose" +) + +// PossibleEventLevelValues returns the possible values for the EventLevel const type. +func PossibleEventLevelValues() []EventLevel { + return []EventLevel{ + EventLevelCritical, + EventLevelError, + EventLevelWarning, + EventLevelInformational, + EventLevelVerbose, + } +} + +// ToPtr returns a *EventLevel pointing to the current value. +func (c EventLevel) ToPtr() *EventLevel { + return &c +} + +// KnownDataCollectionEndpointProvisioningState - The resource provisioning state. This property is READ-ONLY. +type KnownDataCollectionEndpointProvisioningState string + +const ( + KnownDataCollectionEndpointProvisioningStateCreating KnownDataCollectionEndpointProvisioningState = "Creating" + KnownDataCollectionEndpointProvisioningStateDeleting KnownDataCollectionEndpointProvisioningState = "Deleting" + KnownDataCollectionEndpointProvisioningStateFailed KnownDataCollectionEndpointProvisioningState = "Failed" + KnownDataCollectionEndpointProvisioningStateSucceeded KnownDataCollectionEndpointProvisioningState = "Succeeded" + KnownDataCollectionEndpointProvisioningStateUpdating KnownDataCollectionEndpointProvisioningState = "Updating" +) + +// PossibleKnownDataCollectionEndpointProvisioningStateValues returns the possible values for the KnownDataCollectionEndpointProvisioningState const type. +func PossibleKnownDataCollectionEndpointProvisioningStateValues() []KnownDataCollectionEndpointProvisioningState { + return []KnownDataCollectionEndpointProvisioningState{ + KnownDataCollectionEndpointProvisioningStateCreating, + KnownDataCollectionEndpointProvisioningStateDeleting, + KnownDataCollectionEndpointProvisioningStateFailed, + KnownDataCollectionEndpointProvisioningStateSucceeded, + KnownDataCollectionEndpointProvisioningStateUpdating, + } +} + +// ToPtr returns a *KnownDataCollectionEndpointProvisioningState pointing to the current value. +func (c KnownDataCollectionEndpointProvisioningState) ToPtr() *KnownDataCollectionEndpointProvisioningState { + return &c +} + +// KnownDataCollectionEndpointResourceKind - The kind of the resource. +type KnownDataCollectionEndpointResourceKind string + +const ( + KnownDataCollectionEndpointResourceKindLinux KnownDataCollectionEndpointResourceKind = "Linux" + KnownDataCollectionEndpointResourceKindWindows KnownDataCollectionEndpointResourceKind = "Windows" +) + +// PossibleKnownDataCollectionEndpointResourceKindValues returns the possible values for the KnownDataCollectionEndpointResourceKind const type. +func PossibleKnownDataCollectionEndpointResourceKindValues() []KnownDataCollectionEndpointResourceKind { + return []KnownDataCollectionEndpointResourceKind{ + KnownDataCollectionEndpointResourceKindLinux, + KnownDataCollectionEndpointResourceKindWindows, + } +} + +// ToPtr returns a *KnownDataCollectionEndpointResourceKind pointing to the current value. +func (c KnownDataCollectionEndpointResourceKind) ToPtr() *KnownDataCollectionEndpointResourceKind { + return &c +} + +// KnownDataCollectionRuleAssociationProvisioningState - The resource provisioning state. +type KnownDataCollectionRuleAssociationProvisioningState string + +const ( + KnownDataCollectionRuleAssociationProvisioningStateCreating KnownDataCollectionRuleAssociationProvisioningState = "Creating" + KnownDataCollectionRuleAssociationProvisioningStateDeleting KnownDataCollectionRuleAssociationProvisioningState = "Deleting" + KnownDataCollectionRuleAssociationProvisioningStateFailed KnownDataCollectionRuleAssociationProvisioningState = "Failed" + KnownDataCollectionRuleAssociationProvisioningStateSucceeded KnownDataCollectionRuleAssociationProvisioningState = "Succeeded" + KnownDataCollectionRuleAssociationProvisioningStateUpdating KnownDataCollectionRuleAssociationProvisioningState = "Updating" +) + +// PossibleKnownDataCollectionRuleAssociationProvisioningStateValues returns the possible values for the KnownDataCollectionRuleAssociationProvisioningState const type. +func PossibleKnownDataCollectionRuleAssociationProvisioningStateValues() []KnownDataCollectionRuleAssociationProvisioningState { + return []KnownDataCollectionRuleAssociationProvisioningState{ + KnownDataCollectionRuleAssociationProvisioningStateCreating, + KnownDataCollectionRuleAssociationProvisioningStateDeleting, + KnownDataCollectionRuleAssociationProvisioningStateFailed, + KnownDataCollectionRuleAssociationProvisioningStateSucceeded, + KnownDataCollectionRuleAssociationProvisioningStateUpdating, + } +} + +// ToPtr returns a *KnownDataCollectionRuleAssociationProvisioningState pointing to the current value. +func (c KnownDataCollectionRuleAssociationProvisioningState) ToPtr() *KnownDataCollectionRuleAssociationProvisioningState { + return &c +} + +// KnownDataCollectionRuleProvisioningState - The resource provisioning state. +type KnownDataCollectionRuleProvisioningState string + +const ( + KnownDataCollectionRuleProvisioningStateCreating KnownDataCollectionRuleProvisioningState = "Creating" + KnownDataCollectionRuleProvisioningStateDeleting KnownDataCollectionRuleProvisioningState = "Deleting" + KnownDataCollectionRuleProvisioningStateFailed KnownDataCollectionRuleProvisioningState = "Failed" + KnownDataCollectionRuleProvisioningStateSucceeded KnownDataCollectionRuleProvisioningState = "Succeeded" + KnownDataCollectionRuleProvisioningStateUpdating KnownDataCollectionRuleProvisioningState = "Updating" +) + +// PossibleKnownDataCollectionRuleProvisioningStateValues returns the possible values for the KnownDataCollectionRuleProvisioningState const type. +func PossibleKnownDataCollectionRuleProvisioningStateValues() []KnownDataCollectionRuleProvisioningState { + return []KnownDataCollectionRuleProvisioningState{ + KnownDataCollectionRuleProvisioningStateCreating, + KnownDataCollectionRuleProvisioningStateDeleting, + KnownDataCollectionRuleProvisioningStateFailed, + KnownDataCollectionRuleProvisioningStateSucceeded, + KnownDataCollectionRuleProvisioningStateUpdating, + } +} + +// ToPtr returns a *KnownDataCollectionRuleProvisioningState pointing to the current value. +func (c KnownDataCollectionRuleProvisioningState) ToPtr() *KnownDataCollectionRuleProvisioningState { + return &c +} + +// KnownDataCollectionRuleResourceKind - The kind of the resource. +type KnownDataCollectionRuleResourceKind string + +const ( + KnownDataCollectionRuleResourceKindLinux KnownDataCollectionRuleResourceKind = "Linux" + KnownDataCollectionRuleResourceKindWindows KnownDataCollectionRuleResourceKind = "Windows" +) + +// PossibleKnownDataCollectionRuleResourceKindValues returns the possible values for the KnownDataCollectionRuleResourceKind const type. +func PossibleKnownDataCollectionRuleResourceKindValues() []KnownDataCollectionRuleResourceKind { + return []KnownDataCollectionRuleResourceKind{ + KnownDataCollectionRuleResourceKindLinux, + KnownDataCollectionRuleResourceKindWindows, + } +} + +// ToPtr returns a *KnownDataCollectionRuleResourceKind pointing to the current value. +func (c KnownDataCollectionRuleResourceKind) ToPtr() *KnownDataCollectionRuleResourceKind { + return &c +} + +type KnownDataFlowStreams string + +const ( + KnownDataFlowStreamsMicrosoftEvent KnownDataFlowStreams = "Microsoft-Event" + KnownDataFlowStreamsMicrosoftInsightsMetrics KnownDataFlowStreams = "Microsoft-InsightsMetrics" + KnownDataFlowStreamsMicrosoftPerf KnownDataFlowStreams = "Microsoft-Perf" + KnownDataFlowStreamsMicrosoftSyslog KnownDataFlowStreams = "Microsoft-Syslog" + KnownDataFlowStreamsMicrosoftWindowsEvent KnownDataFlowStreams = "Microsoft-WindowsEvent" +) + +// PossibleKnownDataFlowStreamsValues returns the possible values for the KnownDataFlowStreams const type. +func PossibleKnownDataFlowStreamsValues() []KnownDataFlowStreams { + return []KnownDataFlowStreams{ + KnownDataFlowStreamsMicrosoftEvent, + KnownDataFlowStreamsMicrosoftInsightsMetrics, + KnownDataFlowStreamsMicrosoftPerf, + KnownDataFlowStreamsMicrosoftSyslog, + KnownDataFlowStreamsMicrosoftWindowsEvent, + } +} + +// ToPtr returns a *KnownDataFlowStreams pointing to the current value. +func (c KnownDataFlowStreams) ToPtr() *KnownDataFlowStreams { + return &c +} + +type KnownExtensionDataSourceStreams string + +const ( + KnownExtensionDataSourceStreamsMicrosoftEvent KnownExtensionDataSourceStreams = "Microsoft-Event" + KnownExtensionDataSourceStreamsMicrosoftInsightsMetrics KnownExtensionDataSourceStreams = "Microsoft-InsightsMetrics" + KnownExtensionDataSourceStreamsMicrosoftPerf KnownExtensionDataSourceStreams = "Microsoft-Perf" + KnownExtensionDataSourceStreamsMicrosoftSyslog KnownExtensionDataSourceStreams = "Microsoft-Syslog" + KnownExtensionDataSourceStreamsMicrosoftWindowsEvent KnownExtensionDataSourceStreams = "Microsoft-WindowsEvent" +) + +// PossibleKnownExtensionDataSourceStreamsValues returns the possible values for the KnownExtensionDataSourceStreams const type. +func PossibleKnownExtensionDataSourceStreamsValues() []KnownExtensionDataSourceStreams { + return []KnownExtensionDataSourceStreams{ + KnownExtensionDataSourceStreamsMicrosoftEvent, + KnownExtensionDataSourceStreamsMicrosoftInsightsMetrics, + KnownExtensionDataSourceStreamsMicrosoftPerf, + KnownExtensionDataSourceStreamsMicrosoftSyslog, + KnownExtensionDataSourceStreamsMicrosoftWindowsEvent, + } +} + +// ToPtr returns a *KnownExtensionDataSourceStreams pointing to the current value. +func (c KnownExtensionDataSourceStreams) ToPtr() *KnownExtensionDataSourceStreams { + return &c +} + +type KnownPerfCounterDataSourceStreams string + +const ( + KnownPerfCounterDataSourceStreamsMicrosoftInsightsMetrics KnownPerfCounterDataSourceStreams = "Microsoft-InsightsMetrics" + KnownPerfCounterDataSourceStreamsMicrosoftPerf KnownPerfCounterDataSourceStreams = "Microsoft-Perf" +) + +// PossibleKnownPerfCounterDataSourceStreamsValues returns the possible values for the KnownPerfCounterDataSourceStreams const type. +func PossibleKnownPerfCounterDataSourceStreamsValues() []KnownPerfCounterDataSourceStreams { + return []KnownPerfCounterDataSourceStreams{ + KnownPerfCounterDataSourceStreamsMicrosoftInsightsMetrics, + KnownPerfCounterDataSourceStreamsMicrosoftPerf, + } +} + +// ToPtr returns a *KnownPerfCounterDataSourceStreams pointing to the current value. +func (c KnownPerfCounterDataSourceStreams) ToPtr() *KnownPerfCounterDataSourceStreams { + return &c +} + +// KnownPublicNetworkAccessOptions - The configuration to set whether network access from public internet to the endpoints are allowed. +type KnownPublicNetworkAccessOptions string + +const ( + KnownPublicNetworkAccessOptionsDisabled KnownPublicNetworkAccessOptions = "Disabled" + KnownPublicNetworkAccessOptionsEnabled KnownPublicNetworkAccessOptions = "Enabled" +) + +// PossibleKnownPublicNetworkAccessOptionsValues returns the possible values for the KnownPublicNetworkAccessOptions const type. +func PossibleKnownPublicNetworkAccessOptionsValues() []KnownPublicNetworkAccessOptions { + return []KnownPublicNetworkAccessOptions{ + KnownPublicNetworkAccessOptionsDisabled, + KnownPublicNetworkAccessOptionsEnabled, + } +} + +// ToPtr returns a *KnownPublicNetworkAccessOptions pointing to the current value. +func (c KnownPublicNetworkAccessOptions) ToPtr() *KnownPublicNetworkAccessOptions { + return &c +} + +type KnownSyslogDataSourceFacilityNames string + +const ( + KnownSyslogDataSourceFacilityNamesAsterisk KnownSyslogDataSourceFacilityNames = "*" + KnownSyslogDataSourceFacilityNamesAuth KnownSyslogDataSourceFacilityNames = "auth" + KnownSyslogDataSourceFacilityNamesAuthpriv KnownSyslogDataSourceFacilityNames = "authpriv" + KnownSyslogDataSourceFacilityNamesCron KnownSyslogDataSourceFacilityNames = "cron" + KnownSyslogDataSourceFacilityNamesDaemon KnownSyslogDataSourceFacilityNames = "daemon" + KnownSyslogDataSourceFacilityNamesKern KnownSyslogDataSourceFacilityNames = "kern" + KnownSyslogDataSourceFacilityNamesLocal0 KnownSyslogDataSourceFacilityNames = "local0" + KnownSyslogDataSourceFacilityNamesLocal1 KnownSyslogDataSourceFacilityNames = "local1" + KnownSyslogDataSourceFacilityNamesLocal2 KnownSyslogDataSourceFacilityNames = "local2" + KnownSyslogDataSourceFacilityNamesLocal3 KnownSyslogDataSourceFacilityNames = "local3" + KnownSyslogDataSourceFacilityNamesLocal4 KnownSyslogDataSourceFacilityNames = "local4" + KnownSyslogDataSourceFacilityNamesLocal5 KnownSyslogDataSourceFacilityNames = "local5" + KnownSyslogDataSourceFacilityNamesLocal6 KnownSyslogDataSourceFacilityNames = "local6" + KnownSyslogDataSourceFacilityNamesLocal7 KnownSyslogDataSourceFacilityNames = "local7" + KnownSyslogDataSourceFacilityNamesLpr KnownSyslogDataSourceFacilityNames = "lpr" + KnownSyslogDataSourceFacilityNamesMail KnownSyslogDataSourceFacilityNames = "mail" + KnownSyslogDataSourceFacilityNamesMark KnownSyslogDataSourceFacilityNames = "mark" + KnownSyslogDataSourceFacilityNamesNews KnownSyslogDataSourceFacilityNames = "news" + KnownSyslogDataSourceFacilityNamesSyslog KnownSyslogDataSourceFacilityNames = "syslog" + KnownSyslogDataSourceFacilityNamesUser KnownSyslogDataSourceFacilityNames = "user" + KnownSyslogDataSourceFacilityNamesUucp KnownSyslogDataSourceFacilityNames = "uucp" +) + +// PossibleKnownSyslogDataSourceFacilityNamesValues returns the 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, + } +} + +// ToPtr returns a *KnownSyslogDataSourceFacilityNames pointing to the current value. +func (c KnownSyslogDataSourceFacilityNames) ToPtr() *KnownSyslogDataSourceFacilityNames { + return &c +} + +type KnownSyslogDataSourceLogLevels string + +const ( + KnownSyslogDataSourceLogLevelsAlert KnownSyslogDataSourceLogLevels = "Alert" + KnownSyslogDataSourceLogLevelsAsterisk KnownSyslogDataSourceLogLevels = "*" + KnownSyslogDataSourceLogLevelsCritical KnownSyslogDataSourceLogLevels = "Critical" + KnownSyslogDataSourceLogLevelsDebug KnownSyslogDataSourceLogLevels = "Debug" + KnownSyslogDataSourceLogLevelsEmergency KnownSyslogDataSourceLogLevels = "Emergency" + KnownSyslogDataSourceLogLevelsError KnownSyslogDataSourceLogLevels = "Error" + KnownSyslogDataSourceLogLevelsInfo KnownSyslogDataSourceLogLevels = "Info" + KnownSyslogDataSourceLogLevelsNotice KnownSyslogDataSourceLogLevels = "Notice" + KnownSyslogDataSourceLogLevelsWarning KnownSyslogDataSourceLogLevels = "Warning" +) + +// PossibleKnownSyslogDataSourceLogLevelsValues returns the possible values for the KnownSyslogDataSourceLogLevels const type. +func PossibleKnownSyslogDataSourceLogLevelsValues() []KnownSyslogDataSourceLogLevels { + return []KnownSyslogDataSourceLogLevels{ + KnownSyslogDataSourceLogLevelsAlert, + KnownSyslogDataSourceLogLevelsAsterisk, + KnownSyslogDataSourceLogLevelsCritical, + KnownSyslogDataSourceLogLevelsDebug, + KnownSyslogDataSourceLogLevelsEmergency, + KnownSyslogDataSourceLogLevelsError, + KnownSyslogDataSourceLogLevelsInfo, + KnownSyslogDataSourceLogLevelsNotice, + KnownSyslogDataSourceLogLevelsWarning, + } +} + +// ToPtr returns a *KnownSyslogDataSourceLogLevels pointing to the current value. +func (c KnownSyslogDataSourceLogLevels) ToPtr() *KnownSyslogDataSourceLogLevels { + return &c +} + +type KnownSyslogDataSourceStreams string + +const ( + KnownSyslogDataSourceStreamsMicrosoftSyslog KnownSyslogDataSourceStreams = "Microsoft-Syslog" +) + +// PossibleKnownSyslogDataSourceStreamsValues returns the possible values for the KnownSyslogDataSourceStreams const type. +func PossibleKnownSyslogDataSourceStreamsValues() []KnownSyslogDataSourceStreams { + return []KnownSyslogDataSourceStreams{ + KnownSyslogDataSourceStreamsMicrosoftSyslog, + } +} + +// ToPtr returns a *KnownSyslogDataSourceStreams pointing to the current value. +func (c KnownSyslogDataSourceStreams) ToPtr() *KnownSyslogDataSourceStreams { + return &c +} + +type KnownWindowsEventLogDataSourceStreams string + +const ( + KnownWindowsEventLogDataSourceStreamsMicrosoftEvent KnownWindowsEventLogDataSourceStreams = "Microsoft-Event" + KnownWindowsEventLogDataSourceStreamsMicrosoftWindowsEvent KnownWindowsEventLogDataSourceStreams = "Microsoft-WindowsEvent" +) + +// PossibleKnownWindowsEventLogDataSourceStreamsValues returns the possible values for the KnownWindowsEventLogDataSourceStreams const type. +func PossibleKnownWindowsEventLogDataSourceStreamsValues() []KnownWindowsEventLogDataSourceStreams { + return []KnownWindowsEventLogDataSourceStreams{ + KnownWindowsEventLogDataSourceStreamsMicrosoftEvent, + KnownWindowsEventLogDataSourceStreamsMicrosoftWindowsEvent, + } +} + +// ToPtr returns a *KnownWindowsEventLogDataSourceStreams pointing to the current value. +func (c KnownWindowsEventLogDataSourceStreams) ToPtr() *KnownWindowsEventLogDataSourceStreams { + return &c +} + +// MetricClass - The class of the metric. +type MetricClass string + +const ( + MetricClassAvailability MetricClass = "Availability" + MetricClassErrors MetricClass = "Errors" + MetricClassLatency MetricClass = "Latency" + MetricClassSaturation MetricClass = "Saturation" + MetricClassTransactions MetricClass = "Transactions" +) + +// PossibleMetricClassValues returns the possible values for the MetricClass const type. +func PossibleMetricClassValues() []MetricClass { + return []MetricClass{ + MetricClassAvailability, + MetricClassErrors, + MetricClassLatency, + MetricClassSaturation, + MetricClassTransactions, + } +} + +// ToPtr returns a *MetricClass pointing to the current value. +func (c MetricClass) ToPtr() *MetricClass { + return &c +} + +// MetricStatisticType - the metric statistic type. How the metrics from multiple instances are combined. +type MetricStatisticType string + +const ( + MetricStatisticTypeAverage MetricStatisticType = "Average" + MetricStatisticTypeMin MetricStatisticType = "Min" + MetricStatisticTypeMax MetricStatisticType = "Max" + MetricStatisticTypeSum MetricStatisticType = "Sum" + MetricStatisticTypeCount MetricStatisticType = "Count" +) + +// PossibleMetricStatisticTypeValues returns the possible values for the MetricStatisticType const type. +func PossibleMetricStatisticTypeValues() []MetricStatisticType { + return []MetricStatisticType{ + MetricStatisticTypeAverage, + MetricStatisticTypeMin, + MetricStatisticTypeMax, + MetricStatisticTypeSum, + MetricStatisticTypeCount, + } +} + +// ToPtr returns a *MetricStatisticType pointing to the current value. +func (c MetricStatisticType) ToPtr() *MetricStatisticType { + return &c +} + +// MetricTriggerType - Metric Trigger Evaluation Type +type MetricTriggerType string + +const ( + MetricTriggerTypeConsecutive MetricTriggerType = "Consecutive" + MetricTriggerTypeTotal MetricTriggerType = "Total" +) + +// PossibleMetricTriggerTypeValues returns the possible values for the MetricTriggerType const type. +func PossibleMetricTriggerTypeValues() []MetricTriggerType { + return []MetricTriggerType{ + MetricTriggerTypeConsecutive, + MetricTriggerTypeTotal, + } +} + +// ToPtr returns a *MetricTriggerType pointing to the current value. +func (c MetricTriggerType) ToPtr() *MetricTriggerType { + return &c +} + +// MetricUnit - The unit of the metric. +type MetricUnit string + +const ( + MetricUnitBitsPerSecond MetricUnit = "BitsPerSecond" + MetricUnitByteSeconds MetricUnit = "ByteSeconds" + MetricUnitBytes MetricUnit = "Bytes" + MetricUnitBytesPerSecond MetricUnit = "BytesPerSecond" + MetricUnitCores MetricUnit = "Cores" + MetricUnitCount MetricUnit = "Count" + MetricUnitCountPerSecond MetricUnit = "CountPerSecond" + MetricUnitMilliCores MetricUnit = "MilliCores" + MetricUnitMilliSeconds MetricUnit = "MilliSeconds" + MetricUnitNanoCores MetricUnit = "NanoCores" + MetricUnitPercent MetricUnit = "Percent" + MetricUnitSeconds MetricUnit = "Seconds" + MetricUnitUnspecified MetricUnit = "Unspecified" +) + +// PossibleMetricUnitValues returns the possible values for the MetricUnit const type. +func PossibleMetricUnitValues() []MetricUnit { + return []MetricUnit{ + MetricUnitBitsPerSecond, + MetricUnitByteSeconds, + MetricUnitBytes, + MetricUnitBytesPerSecond, + MetricUnitCores, + MetricUnitCount, + MetricUnitCountPerSecond, + MetricUnitMilliCores, + MetricUnitMilliSeconds, + MetricUnitNanoCores, + MetricUnitPercent, + MetricUnitSeconds, + MetricUnitUnspecified, + } +} + +// ToPtr returns a *MetricUnit pointing to the current value. +func (c MetricUnit) ToPtr() *MetricUnit { + return &c +} + +// NamespaceClassification - Kind of namespace +type NamespaceClassification string + +const ( + NamespaceClassificationCustom NamespaceClassification = "Custom" + NamespaceClassificationPlatform NamespaceClassification = "Platform" + NamespaceClassificationQos NamespaceClassification = "Qos" +) + +// PossibleNamespaceClassificationValues returns the possible values for the NamespaceClassification const type. +func PossibleNamespaceClassificationValues() []NamespaceClassification { + return []NamespaceClassification{ + NamespaceClassificationCustom, + NamespaceClassificationPlatform, + NamespaceClassificationQos, + } +} + +// ToPtr returns a *NamespaceClassification pointing to the current value. +func (c NamespaceClassification) ToPtr() *NamespaceClassification { + return &c +} + +// Odatatype - specifies the type of the alert criteria. +type Odatatype string + +const ( + OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria Odatatype = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" + OdatatypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria Odatatype = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" + OdatatypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria Odatatype = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" +) + +// PossibleOdatatypeValues returns the possible values for the Odatatype const type. +func PossibleOdatatypeValues() []Odatatype { + return []Odatatype{ + OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria, + OdatatypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria, + OdatatypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria, + } +} + +// ToPtr returns a *Odatatype pointing to the current value. +func (c Odatatype) ToPtr() *Odatatype { + return &c +} + +// 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. +type OnboardingStatus string + +const ( + OnboardingStatusNotOnboarded OnboardingStatus = "notOnboarded" + OnboardingStatusOnboarded OnboardingStatus = "onboarded" + OnboardingStatusUnknown OnboardingStatus = "unknown" +) + +// PossibleOnboardingStatusValues returns the possible values for the OnboardingStatus const type. +func PossibleOnboardingStatusValues() []OnboardingStatus { + return []OnboardingStatus{ + OnboardingStatusNotOnboarded, + OnboardingStatusOnboarded, + OnboardingStatusUnknown, + } +} + +// ToPtr returns a *OnboardingStatus pointing to the current value. +func (c OnboardingStatus) ToPtr() *OnboardingStatus { + return &c +} + +// Operator - the criteria operator. +type Operator string + +const ( + OperatorEquals Operator = "Equals" + OperatorGreaterThan Operator = "GreaterThan" + OperatorGreaterThanOrEqual Operator = "GreaterThanOrEqual" + OperatorInclude Operator = "Include" + OperatorLessThan Operator = "LessThan" + OperatorLessThanOrEqual Operator = "LessThanOrEqual" + OperatorNotEquals Operator = "NotEquals" +) + +// PossibleOperatorValues returns the possible values for the Operator const type. +func PossibleOperatorValues() []Operator { + return []Operator{ + OperatorEquals, + OperatorGreaterThan, + OperatorGreaterThanOrEqual, + OperatorInclude, + OperatorLessThan, + OperatorLessThanOrEqual, + OperatorNotEquals, + } +} + +// ToPtr returns a *Operator pointing to the current value. +func (c Operator) ToPtr() *Operator { + return &c +} + +// ProvisioningState - Provisioning state of the scheduled query rule +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeploying ProvisioningState = "Deploying" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateDeploying, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// QueryType - Set value to 'ResultAccount' +type QueryType string + +const ( + QueryTypeResultCount QueryType = "ResultCount" +) + +// PossibleQueryTypeValues returns the possible values for the QueryType const type. +func PossibleQueryTypeValues() []QueryType { + return []QueryType{ + QueryTypeResultCount, + } +} + +// ToPtr returns a *QueryType pointing to the current value. +func (c QueryType) ToPtr() *QueryType { + return &c +} + +// ReceiverStatus - Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. +type ReceiverStatus string + +const ( + ReceiverStatusNotSpecified ReceiverStatus = "NotSpecified" + ReceiverStatusEnabled ReceiverStatus = "Enabled" + ReceiverStatusDisabled ReceiverStatus = "Disabled" +) + +// PossibleReceiverStatusValues returns the possible values for the ReceiverStatus const type. +func PossibleReceiverStatusValues() []ReceiverStatus { + return []ReceiverStatus{ + ReceiverStatusNotSpecified, + ReceiverStatusEnabled, + ReceiverStatusDisabled, + } +} + +// ToPtr returns a *ReceiverStatus pointing to the current value. +func (c ReceiverStatus) ToPtr() *ReceiverStatus { + return &c +} + +// RecurrenceFrequency - 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. +type RecurrenceFrequency string + +const ( + RecurrenceFrequencyNone RecurrenceFrequency = "None" + RecurrenceFrequencySecond RecurrenceFrequency = "Second" + RecurrenceFrequencyMinute RecurrenceFrequency = "Minute" + RecurrenceFrequencyHour RecurrenceFrequency = "Hour" + RecurrenceFrequencyDay RecurrenceFrequency = "Day" + RecurrenceFrequencyWeek RecurrenceFrequency = "Week" + RecurrenceFrequencyMonth RecurrenceFrequency = "Month" + RecurrenceFrequencyYear RecurrenceFrequency = "Year" +) + +// PossibleRecurrenceFrequencyValues returns the possible values for the RecurrenceFrequency const type. +func PossibleRecurrenceFrequencyValues() []RecurrenceFrequency { + return []RecurrenceFrequency{ + RecurrenceFrequencyNone, + RecurrenceFrequencySecond, + RecurrenceFrequencyMinute, + RecurrenceFrequencyHour, + RecurrenceFrequencyDay, + RecurrenceFrequencyWeek, + RecurrenceFrequencyMonth, + RecurrenceFrequencyYear, + } +} + +// ToPtr returns a *RecurrenceFrequency pointing to the current value. +func (c RecurrenceFrequency) ToPtr() *RecurrenceFrequency { + return &c +} + +type ResultType string + +const ( + ResultTypeData ResultType = "Data" + ResultTypeMetadata ResultType = "Metadata" +) + +// PossibleResultTypeValues returns the possible values for the ResultType const type. +func PossibleResultTypeValues() []ResultType { + return []ResultType{ + ResultTypeData, + ResultTypeMetadata, + } +} + +// ToPtr returns a *ResultType pointing to the current value. +func (c ResultType) ToPtr() *ResultType { + return &c +} + +// ScaleDirection - the scale direction. Whether the scaling action increases or decreases the number of instances. +type ScaleDirection string + +const ( + ScaleDirectionNone ScaleDirection = "None" + ScaleDirectionIncrease ScaleDirection = "Increase" + ScaleDirectionDecrease ScaleDirection = "Decrease" +) + +// PossibleScaleDirectionValues returns the possible values for the ScaleDirection const type. +func PossibleScaleDirectionValues() []ScaleDirection { + return []ScaleDirection{ + ScaleDirectionNone, + ScaleDirectionIncrease, + ScaleDirectionDecrease, + } +} + +// ToPtr returns a *ScaleDirection pointing to the current value. +func (c ScaleDirection) ToPtr() *ScaleDirection { + return &c +} + +// ScaleRuleMetricDimensionOperationType - 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 +type ScaleRuleMetricDimensionOperationType string + +const ( + ScaleRuleMetricDimensionOperationTypeEquals ScaleRuleMetricDimensionOperationType = "Equals" + ScaleRuleMetricDimensionOperationTypeNotEquals ScaleRuleMetricDimensionOperationType = "NotEquals" +) + +// PossibleScaleRuleMetricDimensionOperationTypeValues returns the possible values for the ScaleRuleMetricDimensionOperationType const type. +func PossibleScaleRuleMetricDimensionOperationTypeValues() []ScaleRuleMetricDimensionOperationType { + return []ScaleRuleMetricDimensionOperationType{ + ScaleRuleMetricDimensionOperationTypeEquals, + ScaleRuleMetricDimensionOperationTypeNotEquals, + } +} + +// ToPtr returns a *ScaleRuleMetricDimensionOperationType pointing to the current value. +func (c ScaleRuleMetricDimensionOperationType) ToPtr() *ScaleRuleMetricDimensionOperationType { + return &c +} + +// ScaleType - the type of action that should occur when the scale rule fires. +type ScaleType string + +const ( + ScaleTypeChangeCount ScaleType = "ChangeCount" + ScaleTypePercentChangeCount ScaleType = "PercentChangeCount" + ScaleTypeExactCount ScaleType = "ExactCount" + ScaleTypeServiceAllowedNextValue ScaleType = "ServiceAllowedNextValue" +) + +// PossibleScaleTypeValues returns the possible values for the ScaleType const type. +func PossibleScaleTypeValues() []ScaleType { + return []ScaleType{ + ScaleTypeChangeCount, + ScaleTypePercentChangeCount, + ScaleTypeExactCount, + ScaleTypeServiceAllowedNextValue, + } +} + +// ToPtr returns a *ScaleType pointing to the current value. +func (c ScaleType) ToPtr() *ScaleType { + return &c +} + +// TimeAggregationOperator - Aggregation operators allowed in a rule. +type TimeAggregationOperator string + +const ( + TimeAggregationOperatorAverage TimeAggregationOperator = "Average" + TimeAggregationOperatorMinimum TimeAggregationOperator = "Minimum" + TimeAggregationOperatorMaximum TimeAggregationOperator = "Maximum" + TimeAggregationOperatorTotal TimeAggregationOperator = "Total" + TimeAggregationOperatorLast TimeAggregationOperator = "Last" +) + +// PossibleTimeAggregationOperatorValues returns the possible values for the TimeAggregationOperator const type. +func PossibleTimeAggregationOperatorValues() []TimeAggregationOperator { + return []TimeAggregationOperator{ + TimeAggregationOperatorAverage, + TimeAggregationOperatorMinimum, + TimeAggregationOperatorMaximum, + TimeAggregationOperatorTotal, + TimeAggregationOperatorLast, + } +} + +// ToPtr returns a *TimeAggregationOperator pointing to the current value. +func (c TimeAggregationOperator) ToPtr() *TimeAggregationOperator { + return &c +} + +// TimeAggregationType - time aggregation type. How the data that is collected should be combined over time. The default value is Average. +type TimeAggregationType string + +const ( + TimeAggregationTypeAverage TimeAggregationType = "Average" + TimeAggregationTypeMinimum TimeAggregationType = "Minimum" + TimeAggregationTypeMaximum TimeAggregationType = "Maximum" + TimeAggregationTypeTotal TimeAggregationType = "Total" + TimeAggregationTypeCount TimeAggregationType = "Count" + TimeAggregationTypeLast TimeAggregationType = "Last" +) + +// PossibleTimeAggregationTypeValues returns the possible values for the TimeAggregationType const type. +func PossibleTimeAggregationTypeValues() []TimeAggregationType { + return []TimeAggregationType{ + TimeAggregationTypeAverage, + TimeAggregationTypeMinimum, + TimeAggregationTypeMaximum, + TimeAggregationTypeTotal, + TimeAggregationTypeCount, + TimeAggregationTypeLast, + } +} + +// ToPtr returns a *TimeAggregationType pointing to the current value. +func (c TimeAggregationType) ToPtr() *TimeAggregationType { + return &c +} diff --git a/sdk/monitor/armmonitor/zz_generated_datacollectionendpoints_client.go b/sdk/monitor/armmonitor/zz_generated_datacollectionendpoints_client.go new file mode 100644 index 000000000000..137df6875750 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_datacollectionendpoints_client.go @@ -0,0 +1,412 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// DataCollectionEndpointsClient contains the methods for the DataCollectionEndpoints group. +// Don't use this type directly, use NewDataCollectionEndpointsClient() instead. +type DataCollectionEndpointsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewDataCollectionEndpointsClient creates a new instance of DataCollectionEndpointsClient with the specified values. +func NewDataCollectionEndpointsClient(con *armcore.Connection, subscriptionID string) *DataCollectionEndpointsClient { + return &DataCollectionEndpointsClient{con: con, subscriptionID: subscriptionID} +} + +// Create - Creates or updates a data collection endpoint. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionEndpointsClient) Create(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, options *DataCollectionEndpointsCreateOptions) (DataCollectionEndpointResourceResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, dataCollectionEndpointName, options) + if err != nil { + return DataCollectionEndpointResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataCollectionEndpointResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return DataCollectionEndpointResourceResponse{}, client.createHandleError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *DataCollectionEndpointsClient) createCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, options *DataCollectionEndpointsCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataCollectionEndpointName == "" { + return nil, errors.New("parameter dataCollectionEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataCollectionEndpointName}", url.PathEscape(dataCollectionEndpointName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, req.MarshalAsJSON(*options.Body) + } + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *DataCollectionEndpointsClient) createHandleResponse(resp *azcore.Response) (DataCollectionEndpointResourceResponse, error) { + var val *DataCollectionEndpointResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionEndpointResourceResponse{}, err + } + return DataCollectionEndpointResourceResponse{RawResponse: resp.Response, DataCollectionEndpointResource: val}, nil +} + +// createHandleError handles the Create error response. +func (client *DataCollectionEndpointsClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes a data collection endpoint. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionEndpointsClient) Delete(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, options *DataCollectionEndpointsDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, dataCollectionEndpointName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp.Response, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DataCollectionEndpointsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, options *DataCollectionEndpointsDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataCollectionEndpointName == "" { + return nil, errors.New("parameter dataCollectionEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataCollectionEndpointName}", url.PathEscape(dataCollectionEndpointName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DataCollectionEndpointsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Returns the specified data collection endpoint. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionEndpointsClient) Get(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, options *DataCollectionEndpointsGetOptions) (DataCollectionEndpointResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, dataCollectionEndpointName, options) + if err != nil { + return DataCollectionEndpointResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataCollectionEndpointResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DataCollectionEndpointResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DataCollectionEndpointsClient) getCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, options *DataCollectionEndpointsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataCollectionEndpointName == "" { + return nil, errors.New("parameter dataCollectionEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataCollectionEndpointName}", url.PathEscape(dataCollectionEndpointName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataCollectionEndpointsClient) getHandleResponse(resp *azcore.Response) (DataCollectionEndpointResourceResponse, error) { + var val *DataCollectionEndpointResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionEndpointResourceResponse{}, err + } + return DataCollectionEndpointResourceResponse{RawResponse: resp.Response, DataCollectionEndpointResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *DataCollectionEndpointsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - Lists all data collection endpoints in the specified resource group. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionEndpointsClient) ListByResourceGroup(resourceGroupName string, options *DataCollectionEndpointsListByResourceGroupOptions) DataCollectionEndpointResourceListResultPager { + return &dataCollectionEndpointResourceListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + responder: client.listByResourceGroupHandleResponse, + errorer: client.listByResourceGroupHandleError, + advancer: func(ctx context.Context, resp DataCollectionEndpointResourceListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.DataCollectionEndpointResourceListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *DataCollectionEndpointsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DataCollectionEndpointsListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *DataCollectionEndpointsClient) listByResourceGroupHandleResponse(resp *azcore.Response) (DataCollectionEndpointResourceListResultResponse, error) { + var val *DataCollectionEndpointResourceListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionEndpointResourceListResultResponse{}, err + } + return DataCollectionEndpointResourceListResultResponse{RawResponse: resp.Response, DataCollectionEndpointResourceListResult: val}, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *DataCollectionEndpointsClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListBySubscription - Lists all data collection endpoints in the specified subscription +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionEndpointsClient) ListBySubscription(options *DataCollectionEndpointsListBySubscriptionOptions) DataCollectionEndpointResourceListResultPager { + return &dataCollectionEndpointResourceListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + responder: client.listBySubscriptionHandleResponse, + errorer: client.listBySubscriptionHandleError, + advancer: func(ctx context.Context, resp DataCollectionEndpointResourceListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.DataCollectionEndpointResourceListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *DataCollectionEndpointsClient) listBySubscriptionCreateRequest(ctx context.Context, options *DataCollectionEndpointsListBySubscriptionOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *DataCollectionEndpointsClient) listBySubscriptionHandleResponse(resp *azcore.Response) (DataCollectionEndpointResourceListResultResponse, error) { + var val *DataCollectionEndpointResourceListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionEndpointResourceListResultResponse{}, err + } + return DataCollectionEndpointResourceListResultResponse{RawResponse: resp.Response, DataCollectionEndpointResourceListResult: val}, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *DataCollectionEndpointsClient) listBySubscriptionHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates part of a data collection endpoint. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionEndpointsClient) Update(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, options *DataCollectionEndpointsUpdateOptions) (DataCollectionEndpointResourceResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, dataCollectionEndpointName, options) + if err != nil { + return DataCollectionEndpointResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataCollectionEndpointResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DataCollectionEndpointResourceResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *DataCollectionEndpointsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, options *DataCollectionEndpointsUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataCollectionEndpointName == "" { + return nil, errors.New("parameter dataCollectionEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataCollectionEndpointName}", url.PathEscape(dataCollectionEndpointName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, req.MarshalAsJSON(*options.Body) + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *DataCollectionEndpointsClient) updateHandleResponse(resp *azcore.Response) (DataCollectionEndpointResourceResponse, error) { + var val *DataCollectionEndpointResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionEndpointResourceResponse{}, err + } + return DataCollectionEndpointResourceResponse{RawResponse: resp.Response, DataCollectionEndpointResource: val}, nil +} + +// updateHandleError handles the Update error response. +func (client *DataCollectionEndpointsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_datacollectionruleassociations_client.go b/sdk/monitor/armmonitor/zz_generated_datacollectionruleassociations_client.go new file mode 100644 index 000000000000..e82582b1b177 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_datacollectionruleassociations_client.go @@ -0,0 +1,335 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// DataCollectionRuleAssociationsClient contains the methods for the DataCollectionRuleAssociations group. +// Don't use this type directly, use NewDataCollectionRuleAssociationsClient() instead. +type DataCollectionRuleAssociationsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewDataCollectionRuleAssociationsClient creates a new instance of DataCollectionRuleAssociationsClient with the specified values. +func NewDataCollectionRuleAssociationsClient(con *armcore.Connection, subscriptionID string) *DataCollectionRuleAssociationsClient { + return &DataCollectionRuleAssociationsClient{con: con, subscriptionID: subscriptionID} +} + +// Create - Creates or updates an association. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionRuleAssociationsClient) Create(ctx context.Context, resourceURI string, associationName string, options *DataCollectionRuleAssociationsCreateOptions) (DataCollectionRuleAssociationProxyOnlyResourceResponse, error) { + req, err := client.createCreateRequest(ctx, resourceURI, associationName, options) + if err != nil { + return DataCollectionRuleAssociationProxyOnlyResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataCollectionRuleAssociationProxyOnlyResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return DataCollectionRuleAssociationProxyOnlyResourceResponse{}, client.createHandleError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *DataCollectionRuleAssociationsClient) createCreateRequest(ctx context.Context, resourceURI string, associationName string, options *DataCollectionRuleAssociationsCreateOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if associationName == "" { + return nil, errors.New("parameter associationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{associationName}", url.PathEscape(associationName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, req.MarshalAsJSON(*options.Body) + } + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *DataCollectionRuleAssociationsClient) createHandleResponse(resp *azcore.Response) (DataCollectionRuleAssociationProxyOnlyResourceResponse, error) { + var val *DataCollectionRuleAssociationProxyOnlyResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionRuleAssociationProxyOnlyResourceResponse{}, err + } + return DataCollectionRuleAssociationProxyOnlyResourceResponse{RawResponse: resp.Response, DataCollectionRuleAssociationProxyOnlyResource: val}, nil +} + +// createHandleError handles the Create error response. +func (client *DataCollectionRuleAssociationsClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes an association. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionRuleAssociationsClient) Delete(ctx context.Context, resourceURI string, associationName string, options *DataCollectionRuleAssociationsDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceURI, associationName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp.Response, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DataCollectionRuleAssociationsClient) deleteCreateRequest(ctx context.Context, resourceURI string, associationName string, options *DataCollectionRuleAssociationsDeleteOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if associationName == "" { + return nil, errors.New("parameter associationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{associationName}", url.PathEscape(associationName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DataCollectionRuleAssociationsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Returns the specified association. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionRuleAssociationsClient) Get(ctx context.Context, resourceURI string, associationName string, options *DataCollectionRuleAssociationsGetOptions) (DataCollectionRuleAssociationProxyOnlyResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceURI, associationName, options) + if err != nil { + return DataCollectionRuleAssociationProxyOnlyResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataCollectionRuleAssociationProxyOnlyResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DataCollectionRuleAssociationProxyOnlyResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DataCollectionRuleAssociationsClient) getCreateRequest(ctx context.Context, resourceURI string, associationName string, options *DataCollectionRuleAssociationsGetOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if associationName == "" { + return nil, errors.New("parameter associationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{associationName}", url.PathEscape(associationName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataCollectionRuleAssociationsClient) getHandleResponse(resp *azcore.Response) (DataCollectionRuleAssociationProxyOnlyResourceResponse, error) { + var val *DataCollectionRuleAssociationProxyOnlyResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionRuleAssociationProxyOnlyResourceResponse{}, err + } + return DataCollectionRuleAssociationProxyOnlyResourceResponse{RawResponse: resp.Response, DataCollectionRuleAssociationProxyOnlyResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *DataCollectionRuleAssociationsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResource - Lists associations for the specified resource. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionRuleAssociationsClient) ListByResource(resourceURI string, options *DataCollectionRuleAssociationsListByResourceOptions) DataCollectionRuleAssociationProxyOnlyResourceListResultPager { + return &dataCollectionRuleAssociationProxyOnlyResourceListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByResourceCreateRequest(ctx, resourceURI, options) + }, + responder: client.listByResourceHandleResponse, + errorer: client.listByResourceHandleError, + advancer: func(ctx context.Context, resp DataCollectionRuleAssociationProxyOnlyResourceListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.DataCollectionRuleAssociationProxyOnlyResourceListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listByResourceCreateRequest creates the ListByResource request. +func (client *DataCollectionRuleAssociationsClient) listByResourceCreateRequest(ctx context.Context, resourceURI string, options *DataCollectionRuleAssociationsListByResourceOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceHandleResponse handles the ListByResource response. +func (client *DataCollectionRuleAssociationsClient) listByResourceHandleResponse(resp *azcore.Response) (DataCollectionRuleAssociationProxyOnlyResourceListResultResponse, error) { + var val *DataCollectionRuleAssociationProxyOnlyResourceListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionRuleAssociationProxyOnlyResourceListResultResponse{}, err + } + return DataCollectionRuleAssociationProxyOnlyResourceListResultResponse{RawResponse: resp.Response, DataCollectionRuleAssociationProxyOnlyResourceListResult: val}, nil +} + +// listByResourceHandleError handles the ListByResource error response. +func (client *DataCollectionRuleAssociationsClient) listByResourceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByRule - Lists associations for the specified data collection rule. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionRuleAssociationsClient) ListByRule(resourceGroupName string, dataCollectionRuleName string, options *DataCollectionRuleAssociationsListByRuleOptions) DataCollectionRuleAssociationProxyOnlyResourceListResultPager { + return &dataCollectionRuleAssociationProxyOnlyResourceListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByRuleCreateRequest(ctx, resourceGroupName, dataCollectionRuleName, options) + }, + responder: client.listByRuleHandleResponse, + errorer: client.listByRuleHandleError, + advancer: func(ctx context.Context, resp DataCollectionRuleAssociationProxyOnlyResourceListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.DataCollectionRuleAssociationProxyOnlyResourceListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listByRuleCreateRequest creates the ListByRule request. +func (client *DataCollectionRuleAssociationsClient) listByRuleCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, options *DataCollectionRuleAssociationsListByRuleOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataCollectionRuleName == "" { + return nil, errors.New("parameter dataCollectionRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataCollectionRuleName}", url.PathEscape(dataCollectionRuleName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByRuleHandleResponse handles the ListByRule response. +func (client *DataCollectionRuleAssociationsClient) listByRuleHandleResponse(resp *azcore.Response) (DataCollectionRuleAssociationProxyOnlyResourceListResultResponse, error) { + var val *DataCollectionRuleAssociationProxyOnlyResourceListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionRuleAssociationProxyOnlyResourceListResultResponse{}, err + } + return DataCollectionRuleAssociationProxyOnlyResourceListResultResponse{RawResponse: resp.Response, DataCollectionRuleAssociationProxyOnlyResourceListResult: val}, nil +} + +// listByRuleHandleError handles the ListByRule error response. +func (client *DataCollectionRuleAssociationsClient) listByRuleHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_datacollectionrules_client.go b/sdk/monitor/armmonitor/zz_generated_datacollectionrules_client.go new file mode 100644 index 000000000000..cf93d6dcde44 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_datacollectionrules_client.go @@ -0,0 +1,412 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// DataCollectionRulesClient contains the methods for the DataCollectionRules group. +// Don't use this type directly, use NewDataCollectionRulesClient() instead. +type DataCollectionRulesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewDataCollectionRulesClient creates a new instance of DataCollectionRulesClient with the specified values. +func NewDataCollectionRulesClient(con *armcore.Connection, subscriptionID string) *DataCollectionRulesClient { + return &DataCollectionRulesClient{con: con, subscriptionID: subscriptionID} +} + +// Create - Creates or updates a data collection rule. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionRulesClient) Create(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, options *DataCollectionRulesCreateOptions) (DataCollectionRuleResourceResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, dataCollectionRuleName, options) + if err != nil { + return DataCollectionRuleResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataCollectionRuleResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return DataCollectionRuleResourceResponse{}, client.createHandleError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *DataCollectionRulesClient) createCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, options *DataCollectionRulesCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataCollectionRuleName == "" { + return nil, errors.New("parameter dataCollectionRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataCollectionRuleName}", url.PathEscape(dataCollectionRuleName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, req.MarshalAsJSON(*options.Body) + } + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *DataCollectionRulesClient) createHandleResponse(resp *azcore.Response) (DataCollectionRuleResourceResponse, error) { + var val *DataCollectionRuleResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionRuleResourceResponse{}, err + } + return DataCollectionRuleResourceResponse{RawResponse: resp.Response, DataCollectionRuleResource: val}, nil +} + +// createHandleError handles the Create error response. +func (client *DataCollectionRulesClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes a data collection rule. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionRulesClient) Delete(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, options *DataCollectionRulesDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, dataCollectionRuleName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp.Response, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DataCollectionRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, options *DataCollectionRulesDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataCollectionRuleName == "" { + return nil, errors.New("parameter dataCollectionRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataCollectionRuleName}", url.PathEscape(dataCollectionRuleName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DataCollectionRulesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Returns the specified data collection rule. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionRulesClient) Get(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, options *DataCollectionRulesGetOptions) (DataCollectionRuleResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, dataCollectionRuleName, options) + if err != nil { + return DataCollectionRuleResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataCollectionRuleResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DataCollectionRuleResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DataCollectionRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, options *DataCollectionRulesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataCollectionRuleName == "" { + return nil, errors.New("parameter dataCollectionRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataCollectionRuleName}", url.PathEscape(dataCollectionRuleName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataCollectionRulesClient) getHandleResponse(resp *azcore.Response) (DataCollectionRuleResourceResponse, error) { + var val *DataCollectionRuleResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionRuleResourceResponse{}, err + } + return DataCollectionRuleResourceResponse{RawResponse: resp.Response, DataCollectionRuleResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *DataCollectionRulesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - Lists all data collection rules in the specified resource group. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionRulesClient) ListByResourceGroup(resourceGroupName string, options *DataCollectionRulesListByResourceGroupOptions) DataCollectionRuleResourceListResultPager { + return &dataCollectionRuleResourceListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + responder: client.listByResourceGroupHandleResponse, + errorer: client.listByResourceGroupHandleError, + advancer: func(ctx context.Context, resp DataCollectionRuleResourceListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.DataCollectionRuleResourceListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *DataCollectionRulesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DataCollectionRulesListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *DataCollectionRulesClient) listByResourceGroupHandleResponse(resp *azcore.Response) (DataCollectionRuleResourceListResultResponse, error) { + var val *DataCollectionRuleResourceListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionRuleResourceListResultResponse{}, err + } + return DataCollectionRuleResourceListResultResponse{RawResponse: resp.Response, DataCollectionRuleResourceListResult: val}, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *DataCollectionRulesClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListBySubscription - Lists all data collection rules in the specified subscription. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionRulesClient) ListBySubscription(options *DataCollectionRulesListBySubscriptionOptions) DataCollectionRuleResourceListResultPager { + return &dataCollectionRuleResourceListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + responder: client.listBySubscriptionHandleResponse, + errorer: client.listBySubscriptionHandleError, + advancer: func(ctx context.Context, resp DataCollectionRuleResourceListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.DataCollectionRuleResourceListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *DataCollectionRulesClient) listBySubscriptionCreateRequest(ctx context.Context, options *DataCollectionRulesListBySubscriptionOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *DataCollectionRulesClient) listBySubscriptionHandleResponse(resp *azcore.Response) (DataCollectionRuleResourceListResultResponse, error) { + var val *DataCollectionRuleResourceListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionRuleResourceListResultResponse{}, err + } + return DataCollectionRuleResourceListResultResponse{RawResponse: resp.Response, DataCollectionRuleResourceListResult: val}, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *DataCollectionRulesClient) listBySubscriptionHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates part of a data collection rule. +// If the operation fails it returns the *ErrorResponseCommonV2 error type. +func (client *DataCollectionRulesClient) Update(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, options *DataCollectionRulesUpdateOptions) (DataCollectionRuleResourceResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, dataCollectionRuleName, options) + if err != nil { + return DataCollectionRuleResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DataCollectionRuleResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DataCollectionRuleResourceResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *DataCollectionRulesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, options *DataCollectionRulesUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataCollectionRuleName == "" { + return nil, errors.New("parameter dataCollectionRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataCollectionRuleName}", url.PathEscape(dataCollectionRuleName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + if options != nil && options.Body != nil { + return req, req.MarshalAsJSON(*options.Body) + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *DataCollectionRulesClient) updateHandleResponse(resp *azcore.Response) (DataCollectionRuleResourceResponse, error) { + var val *DataCollectionRuleResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DataCollectionRuleResourceResponse{}, err + } + return DataCollectionRuleResourceResponse{RawResponse: resp.Response, DataCollectionRuleResource: val}, nil +} + +// updateHandleError handles the Update error response. +func (client *DataCollectionRulesClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponseCommonV2{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_diagnosticsettings_client.go b/sdk/monitor/armmonitor/zz_generated_diagnosticsettings_client.go new file mode 100644 index 000000000000..509343a08ac5 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_diagnosticsettings_client.go @@ -0,0 +1,265 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// DiagnosticSettingsClient contains the methods for the DiagnosticSettings group. +// Don't use this type directly, use NewDiagnosticSettingsClient() instead. +type DiagnosticSettingsClient struct { + con *armcore.Connection +} + +// NewDiagnosticSettingsClient creates a new instance of DiagnosticSettingsClient with the specified values. +func NewDiagnosticSettingsClient(con *armcore.Connection) *DiagnosticSettingsClient { + return &DiagnosticSettingsClient{con: con} +} + +// CreateOrUpdate - Creates or updates diagnostic settings for the specified resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticSettingsClient) CreateOrUpdate(ctx context.Context, resourceURI string, name string, parameters DiagnosticSettingsResource, options *DiagnosticSettingsCreateOrUpdateOptions) (DiagnosticSettingsResourceResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceURI, name, parameters, options) + if err != nil { + return DiagnosticSettingsResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DiagnosticSettingsResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DiagnosticSettingsResourceResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DiagnosticSettingsClient) createOrUpdateCreateRequest(ctx context.Context, resourceURI string, name string, parameters DiagnosticSettingsResource, options *DiagnosticSettingsCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-05-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *DiagnosticSettingsClient) createOrUpdateHandleResponse(resp *azcore.Response) (DiagnosticSettingsResourceResponse, error) { + var val *DiagnosticSettingsResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DiagnosticSettingsResourceResponse{}, err + } + return DiagnosticSettingsResourceResponse{RawResponse: resp.Response, DiagnosticSettingsResource: val}, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *DiagnosticSettingsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes existing diagnostic settings for the specified resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticSettingsClient) Delete(ctx context.Context, resourceURI string, name string, options *DiagnosticSettingsDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceURI, name, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp.Response, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DiagnosticSettingsClient) deleteCreateRequest(ctx context.Context, resourceURI string, name string, options *DiagnosticSettingsDeleteOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-05-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DiagnosticSettingsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the active diagnostic settings for the specified resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticSettingsClient) Get(ctx context.Context, resourceURI string, name string, options *DiagnosticSettingsGetOptions) (DiagnosticSettingsResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceURI, name, options) + if err != nil { + return DiagnosticSettingsResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DiagnosticSettingsResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DiagnosticSettingsResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DiagnosticSettingsClient) getCreateRequest(ctx context.Context, resourceURI string, name string, options *DiagnosticSettingsGetOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-05-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DiagnosticSettingsClient) getHandleResponse(resp *azcore.Response) (DiagnosticSettingsResourceResponse, error) { + var val *DiagnosticSettingsResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DiagnosticSettingsResourceResponse{}, err + } + return DiagnosticSettingsResourceResponse{RawResponse: resp.Response, DiagnosticSettingsResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *DiagnosticSettingsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Gets the active diagnostic settings list for the specified resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticSettingsClient) List(ctx context.Context, resourceURI string, options *DiagnosticSettingsListOptions) (DiagnosticSettingsResourceCollectionResponse, error) { + req, err := client.listCreateRequest(ctx, resourceURI, options) + if err != nil { + return DiagnosticSettingsResourceCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DiagnosticSettingsResourceCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DiagnosticSettingsResourceCollectionResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *DiagnosticSettingsClient) listCreateRequest(ctx context.Context, resourceURI string, options *DiagnosticSettingsListOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-05-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DiagnosticSettingsClient) listHandleResponse(resp *azcore.Response) (DiagnosticSettingsResourceCollectionResponse, error) { + var val *DiagnosticSettingsResourceCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DiagnosticSettingsResourceCollectionResponse{}, err + } + return DiagnosticSettingsResourceCollectionResponse{RawResponse: resp.Response, DiagnosticSettingsResourceCollection: val}, nil +} + +// listHandleError handles the List error response. +func (client *DiagnosticSettingsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_diagnosticsettingscategory_client.go b/sdk/monitor/armmonitor/zz_generated_diagnosticsettingscategory_client.go new file mode 100644 index 000000000000..b76f4eada468 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_diagnosticsettingscategory_client.go @@ -0,0 +1,150 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// DiagnosticSettingsCategoryClient contains the methods for the DiagnosticSettingsCategory group. +// Don't use this type directly, use NewDiagnosticSettingsCategoryClient() instead. +type DiagnosticSettingsCategoryClient struct { + con *armcore.Connection +} + +// NewDiagnosticSettingsCategoryClient creates a new instance of DiagnosticSettingsCategoryClient with the specified values. +func NewDiagnosticSettingsCategoryClient(con *armcore.Connection) *DiagnosticSettingsCategoryClient { + return &DiagnosticSettingsCategoryClient{con: con} +} + +// Get - Gets the diagnostic settings category for the specified resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticSettingsCategoryClient) Get(ctx context.Context, resourceURI string, name string, options *DiagnosticSettingsCategoryGetOptions) (DiagnosticSettingsCategoryResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceURI, name, options) + if err != nil { + return DiagnosticSettingsCategoryResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DiagnosticSettingsCategoryResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DiagnosticSettingsCategoryResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DiagnosticSettingsCategoryClient) getCreateRequest(ctx context.Context, resourceURI string, name string, options *DiagnosticSettingsCategoryGetOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-05-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DiagnosticSettingsCategoryClient) getHandleResponse(resp *azcore.Response) (DiagnosticSettingsCategoryResourceResponse, error) { + var val *DiagnosticSettingsCategoryResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DiagnosticSettingsCategoryResourceResponse{}, err + } + return DiagnosticSettingsCategoryResourceResponse{RawResponse: resp.Response, DiagnosticSettingsCategoryResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *DiagnosticSettingsCategoryClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Lists the diagnostic settings categories for the specified resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticSettingsCategoryClient) List(ctx context.Context, resourceURI string, options *DiagnosticSettingsCategoryListOptions) (DiagnosticSettingsCategoryResourceCollectionResponse, error) { + req, err := client.listCreateRequest(ctx, resourceURI, options) + if err != nil { + return DiagnosticSettingsCategoryResourceCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DiagnosticSettingsCategoryResourceCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DiagnosticSettingsCategoryResourceCollectionResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *DiagnosticSettingsCategoryClient) listCreateRequest(ctx context.Context, resourceURI string, options *DiagnosticSettingsCategoryListOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-05-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DiagnosticSettingsCategoryClient) listHandleResponse(resp *azcore.Response) (DiagnosticSettingsCategoryResourceCollectionResponse, error) { + var val *DiagnosticSettingsCategoryResourceCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return DiagnosticSettingsCategoryResourceCollectionResponse{}, err + } + return DiagnosticSettingsCategoryResourceCollectionResponse{RawResponse: resp.Response, DiagnosticSettingsCategoryResourceCollection: val}, nil +} + +// listHandleError handles the List error response. +func (client *DiagnosticSettingsCategoryClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_eventcategories_client.go b/sdk/monitor/armmonitor/zz_generated_eventcategories_client.go new file mode 100644 index 000000000000..23253507c663 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_eventcategories_client.go @@ -0,0 +1,82 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// EventCategoriesClient contains the methods for the EventCategories group. +// Don't use this type directly, use NewEventCategoriesClient() instead. +type EventCategoriesClient struct { + con *armcore.Connection +} + +// NewEventCategoriesClient creates a new instance of EventCategoriesClient with the specified values. +func NewEventCategoriesClient(con *armcore.Connection) *EventCategoriesClient { + return &EventCategoriesClient{con: con} +} + +// 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. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EventCategoriesClient) List(ctx context.Context, options *EventCategoriesListOptions) (EventCategoryCollectionResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return EventCategoryCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return EventCategoryCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return EventCategoryCollectionResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *EventCategoriesClient) listCreateRequest(ctx context.Context, options *EventCategoriesListOptions) (*azcore.Request, error) { + urlPath := "/providers/Microsoft.Insights/eventcategories" + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2015-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *EventCategoriesClient) listHandleResponse(resp *azcore.Response) (EventCategoryCollectionResponse, error) { + var val *EventCategoryCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return EventCategoryCollectionResponse{}, err + } + return EventCategoryCollectionResponse{RawResponse: resp.Response, EventCategoryCollection: val}, nil +} + +// listHandleError handles the List error response. +func (client *EventCategoriesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_logprofiles_client.go b/sdk/monitor/armmonitor/zz_generated_logprofiles_client.go new file mode 100644 index 000000000000..04a4a8ea07de --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_logprofiles_client.go @@ -0,0 +1,324 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// LogProfilesClient contains the methods for the LogProfiles group. +// Don't use this type directly, use NewLogProfilesClient() instead. +type LogProfilesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewLogProfilesClient creates a new instance of LogProfilesClient with the specified values. +func NewLogProfilesClient(con *armcore.Connection, subscriptionID string) *LogProfilesClient { + return &LogProfilesClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or update a log profile in Azure Monitoring REST API. +// If the operation fails it returns a generic error. +func (client *LogProfilesClient) CreateOrUpdate(ctx context.Context, logProfileName string, parameters LogProfileResource, options *LogProfilesCreateOrUpdateOptions) (LogProfileResourceResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, logProfileName, parameters, options) + if err != nil { + return LogProfileResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LogProfileResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LogProfileResourceResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *LogProfilesClient) createOrUpdateCreateRequest(ctx context.Context, logProfileName string, parameters LogProfileResource, options *LogProfilesCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + if logProfileName == "" { + return nil, errors.New("parameter logProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{logProfileName}", url.PathEscape(logProfileName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *LogProfilesClient) createOrUpdateHandleResponse(resp *azcore.Response) (LogProfileResourceResponse, error) { + var val *LogProfileResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return LogProfileResourceResponse{}, err + } + return LogProfileResourceResponse{RawResponse: resp.Response, LogProfileResource: val}, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *LogProfilesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Delete - Deletes the log profile. +// If the operation fails it returns a generic error. +func (client *LogProfilesClient) Delete(ctx context.Context, logProfileName string, options *LogProfilesDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, logProfileName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK) { + return nil, client.deleteHandleError(resp) + } + return resp.Response, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *LogProfilesClient) deleteCreateRequest(ctx context.Context, logProfileName string, options *LogProfilesDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + if logProfileName == "" { + return nil, errors.New("parameter logProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{logProfileName}", url.PathEscape(logProfileName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *LogProfilesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets the log profile. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LogProfilesClient) Get(ctx context.Context, logProfileName string, options *LogProfilesGetOptions) (LogProfileResourceResponse, error) { + req, err := client.getCreateRequest(ctx, logProfileName, options) + if err != nil { + return LogProfileResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LogProfileResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LogProfileResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *LogProfilesClient) getCreateRequest(ctx context.Context, logProfileName string, options *LogProfilesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + if logProfileName == "" { + return nil, errors.New("parameter logProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{logProfileName}", url.PathEscape(logProfileName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *LogProfilesClient) getHandleResponse(resp *azcore.Response) (LogProfileResourceResponse, error) { + var val *LogProfileResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return LogProfileResourceResponse{}, err + } + return LogProfileResourceResponse{RawResponse: resp.Response, LogProfileResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *LogProfilesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - List the log profiles. +// If the operation fails it returns a generic error. +func (client *LogProfilesClient) List(ctx context.Context, options *LogProfilesListOptions) (LogProfileCollectionResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return LogProfileCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LogProfileCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LogProfileCollectionResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *LogProfilesClient) listCreateRequest(ctx context.Context, options *LogProfilesListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *LogProfilesClient) listHandleResponse(resp *azcore.Response) (LogProfileCollectionResponse, error) { + var val *LogProfileCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return LogProfileCollectionResponse{}, err + } + return LogProfileCollectionResponse{RawResponse: resp.Response, LogProfileCollection: val}, nil +} + +// listHandleError handles the List error response. +func (client *LogProfilesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Update - Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LogProfilesClient) Update(ctx context.Context, logProfileName string, logProfilesResource LogProfileResourcePatch, options *LogProfilesUpdateOptions) (LogProfileResourceResponse, error) { + req, err := client.updateCreateRequest(ctx, logProfileName, logProfilesResource, options) + if err != nil { + return LogProfileResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LogProfileResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LogProfileResourceResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *LogProfilesClient) updateCreateRequest(ctx context.Context, logProfileName string, logProfilesResource LogProfileResourcePatch, options *LogProfilesUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if logProfileName == "" { + return nil, errors.New("parameter logProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{logProfileName}", url.PathEscape(logProfileName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2016-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(logProfilesResource) +} + +// updateHandleResponse handles the Update response. +func (client *LogProfilesClient) updateHandleResponse(resp *azcore.Response) (LogProfileResourceResponse, error) { + var val *LogProfileResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return LogProfileResourceResponse{}, err + } + return LogProfileResourceResponse{RawResponse: resp.Response, LogProfileResource: val}, nil +} + +// updateHandleError handles the Update error response. +func (client *LogProfilesClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_metricalerts_client.go b/sdk/monitor/armmonitor/zz_generated_metricalerts_client.go new file mode 100644 index 000000000000..c9bc94abc054 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_metricalerts_client.go @@ -0,0 +1,406 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// MetricAlertsClient contains the methods for the MetricAlerts group. +// Don't use this type directly, use NewMetricAlertsClient() instead. +type MetricAlertsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewMetricAlertsClient creates a new instance of MetricAlertsClient with the specified values. +func NewMetricAlertsClient(con *armcore.Connection, subscriptionID string) *MetricAlertsClient { + return &MetricAlertsClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or update an metric alert definition. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MetricAlertsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResource, options *MetricAlertsCreateOrUpdateOptions) (MetricAlertResourceResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, ruleName, parameters, options) + if err != nil { + return MetricAlertResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return MetricAlertResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return MetricAlertResourceResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *MetricAlertsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResource, options *MetricAlertsCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *MetricAlertsClient) createOrUpdateHandleResponse(resp *azcore.Response) (MetricAlertResourceResponse, error) { + var val *MetricAlertResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return MetricAlertResourceResponse{}, err + } + return MetricAlertResourceResponse{RawResponse: resp.Response, MetricAlertResource: val}, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *MetricAlertsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Delete an alert rule definition. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MetricAlertsClient) Delete(ctx context.Context, resourceGroupName string, ruleName string, options *MetricAlertsDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, ruleName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp.Response, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *MetricAlertsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, options *MetricAlertsDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *MetricAlertsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Retrieve an alert rule definition. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MetricAlertsClient) Get(ctx context.Context, resourceGroupName string, ruleName string, options *MetricAlertsGetOptions) (MetricAlertResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, ruleName, options) + if err != nil { + return MetricAlertResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return MetricAlertResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return MetricAlertResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *MetricAlertsClient) getCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, options *MetricAlertsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *MetricAlertsClient) getHandleResponse(resp *azcore.Response) (MetricAlertResourceResponse, error) { + var val *MetricAlertResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return MetricAlertResourceResponse{}, err + } + return MetricAlertResourceResponse{RawResponse: resp.Response, MetricAlertResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *MetricAlertsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - Retrieve alert rule definitions in a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MetricAlertsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *MetricAlertsListByResourceGroupOptions) (MetricAlertResourceCollectionResponse, error) { + req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return MetricAlertResourceCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return MetricAlertResourceCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return MetricAlertResourceCollectionResponse{}, client.listByResourceGroupHandleError(resp) + } + return client.listByResourceGroupHandleResponse(resp) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *MetricAlertsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *MetricAlertsListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *MetricAlertsClient) listByResourceGroupHandleResponse(resp *azcore.Response) (MetricAlertResourceCollectionResponse, error) { + var val *MetricAlertResourceCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return MetricAlertResourceCollectionResponse{}, err + } + return MetricAlertResourceCollectionResponse{RawResponse: resp.Response, MetricAlertResourceCollection: val}, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *MetricAlertsClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListBySubscription - Retrieve alert rule definitions in a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MetricAlertsClient) ListBySubscription(ctx context.Context, options *MetricAlertsListBySubscriptionOptions) (MetricAlertResourceCollectionResponse, error) { + req, err := client.listBySubscriptionCreateRequest(ctx, options) + if err != nil { + return MetricAlertResourceCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return MetricAlertResourceCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return MetricAlertResourceCollectionResponse{}, client.listBySubscriptionHandleError(resp) + } + return client.listBySubscriptionHandleResponse(resp) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *MetricAlertsClient) listBySubscriptionCreateRequest(ctx context.Context, options *MetricAlertsListBySubscriptionOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *MetricAlertsClient) listBySubscriptionHandleResponse(resp *azcore.Response) (MetricAlertResourceCollectionResponse, error) { + var val *MetricAlertResourceCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return MetricAlertResourceCollectionResponse{}, err + } + return MetricAlertResourceCollectionResponse{RawResponse: resp.Response, MetricAlertResourceCollection: val}, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *MetricAlertsClient) listBySubscriptionHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Update an metric alert definition. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MetricAlertsClient) Update(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResourcePatch, options *MetricAlertsUpdateOptions) (MetricAlertResourceResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, ruleName, parameters, options) + if err != nil { + return MetricAlertResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return MetricAlertResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return MetricAlertResourceResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *MetricAlertsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResourcePatch, options *MetricAlertsUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *MetricAlertsClient) updateHandleResponse(resp *azcore.Response) (MetricAlertResourceResponse, error) { + var val *MetricAlertResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return MetricAlertResourceResponse{}, err + } + return MetricAlertResourceResponse{RawResponse: resp.Response, MetricAlertResource: val}, nil +} + +// updateHandleError handles the Update error response. +func (client *MetricAlertsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_metricalertsstatus_client.go b/sdk/monitor/armmonitor/zz_generated_metricalertsstatus_client.go new file mode 100644 index 000000000000..eca090daace0 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_metricalertsstatus_client.go @@ -0,0 +1,167 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// MetricAlertsStatusClient contains the methods for the MetricAlertsStatus group. +// Don't use this type directly, use NewMetricAlertsStatusClient() instead. +type MetricAlertsStatusClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewMetricAlertsStatusClient creates a new instance of MetricAlertsStatusClient with the specified values. +func NewMetricAlertsStatusClient(con *armcore.Connection, subscriptionID string) *MetricAlertsStatusClient { + return &MetricAlertsStatusClient{con: con, subscriptionID: subscriptionID} +} + +// List - Retrieve an alert rule status. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MetricAlertsStatusClient) List(ctx context.Context, resourceGroupName string, ruleName string, options *MetricAlertsStatusListOptions) (MetricAlertStatusCollectionResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, ruleName, options) + if err != nil { + return MetricAlertStatusCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return MetricAlertStatusCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return MetricAlertStatusCollectionResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *MetricAlertsStatusClient) listCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, options *MetricAlertsStatusListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *MetricAlertsStatusClient) listHandleResponse(resp *azcore.Response) (MetricAlertStatusCollectionResponse, error) { + var val *MetricAlertStatusCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return MetricAlertStatusCollectionResponse{}, err + } + return MetricAlertStatusCollectionResponse{RawResponse: resp.Response, MetricAlertStatusCollection: val}, nil +} + +// listHandleError handles the List error response. +func (client *MetricAlertsStatusClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByName - Retrieve an alert rule status. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MetricAlertsStatusClient) ListByName(ctx context.Context, resourceGroupName string, ruleName string, statusName string, options *MetricAlertsStatusListByNameOptions) (MetricAlertStatusCollectionResponse, error) { + req, err := client.listByNameCreateRequest(ctx, resourceGroupName, ruleName, statusName, options) + if err != nil { + return MetricAlertStatusCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return MetricAlertStatusCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return MetricAlertStatusCollectionResponse{}, client.listByNameHandleError(resp) + } + return client.listByNameHandleResponse(resp) +} + +// listByNameCreateRequest creates the ListByName request. +func (client *MetricAlertsStatusClient) listByNameCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, statusName string, options *MetricAlertsStatusListByNameOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + if statusName == "" { + return nil, errors.New("parameter statusName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{statusName}", url.PathEscape(statusName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-03-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByNameHandleResponse handles the ListByName response. +func (client *MetricAlertsStatusClient) listByNameHandleResponse(resp *azcore.Response) (MetricAlertStatusCollectionResponse, error) { + var val *MetricAlertStatusCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return MetricAlertStatusCollectionResponse{}, err + } + return MetricAlertStatusCollectionResponse{RawResponse: resp.Response, MetricAlertStatusCollection: val}, nil +} + +// listByNameHandleError handles the ListByName error response. +func (client *MetricAlertsStatusClient) listByNameHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_metricdefinitions_client.go b/sdk/monitor/armmonitor/zz_generated_metricdefinitions_client.go new file mode 100644 index 000000000000..1caaa6a8432a --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_metricdefinitions_client.go @@ -0,0 +1,90 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "strings" +) + +// MetricDefinitionsClient contains the methods for the MetricDefinitions group. +// Don't use this type directly, use NewMetricDefinitionsClient() instead. +type MetricDefinitionsClient struct { + con *armcore.Connection +} + +// NewMetricDefinitionsClient creates a new instance of MetricDefinitionsClient with the specified values. +func NewMetricDefinitionsClient(con *armcore.Connection) *MetricDefinitionsClient { + return &MetricDefinitionsClient{con: con} +} + +// List - Lists the metric definitions for the resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MetricDefinitionsClient) List(ctx context.Context, resourceURI string, options *MetricDefinitionsListOptions) (MetricDefinitionCollectionResponse, error) { + req, err := client.listCreateRequest(ctx, resourceURI, options) + if err != nil { + return MetricDefinitionCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return MetricDefinitionCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return MetricDefinitionCollectionResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *MetricDefinitionsClient) listCreateRequest(ctx context.Context, resourceURI string, options *MetricDefinitionsListOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-01-01") + if options != nil && options.Metricnamespace != nil { + reqQP.Set("metricnamespace", *options.Metricnamespace) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *MetricDefinitionsClient) listHandleResponse(resp *azcore.Response) (MetricDefinitionCollectionResponse, error) { + var val *MetricDefinitionCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return MetricDefinitionCollectionResponse{}, err + } + return MetricDefinitionCollectionResponse{RawResponse: resp.Response, MetricDefinitionCollection: val}, nil +} + +// listHandleError handles the List error response. +func (client *MetricDefinitionsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_metricnamespaces_client.go b/sdk/monitor/armmonitor/zz_generated_metricnamespaces_client.go new file mode 100644 index 000000000000..5098ef407f9d --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_metricnamespaces_client.go @@ -0,0 +1,90 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "strings" +) + +// MetricNamespacesClient contains the methods for the MetricNamespaces group. +// Don't use this type directly, use NewMetricNamespacesClient() instead. +type MetricNamespacesClient struct { + con *armcore.Connection +} + +// NewMetricNamespacesClient creates a new instance of MetricNamespacesClient with the specified values. +func NewMetricNamespacesClient(con *armcore.Connection) *MetricNamespacesClient { + return &MetricNamespacesClient{con: con} +} + +// List - Lists the metric namespaces for the resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MetricNamespacesClient) List(ctx context.Context, resourceURI string, options *MetricNamespacesListOptions) (MetricNamespaceCollectionResponse, error) { + req, err := client.listCreateRequest(ctx, resourceURI, options) + if err != nil { + return MetricNamespaceCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return MetricNamespaceCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return MetricNamespaceCollectionResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *MetricNamespacesClient) listCreateRequest(ctx context.Context, resourceURI string, options *MetricNamespacesListOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/microsoft.insights/metricNamespaces" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2017-12-01-preview") + if options != nil && options.StartTime != nil { + reqQP.Set("startTime", *options.StartTime) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *MetricNamespacesClient) listHandleResponse(resp *azcore.Response) (MetricNamespaceCollectionResponse, error) { + var val *MetricNamespaceCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return MetricNamespaceCollectionResponse{}, err + } + return MetricNamespaceCollectionResponse{RawResponse: resp.Response, MetricNamespaceCollection: val}, nil +} + +// listHandleError handles the List error response. +func (client *MetricNamespacesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_metrics_client.go b/sdk/monitor/armmonitor/zz_generated_metrics_client.go new file mode 100644 index 000000000000..53b166ecdef6 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_metrics_client.go @@ -0,0 +1,115 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "strconv" + "strings" +) + +// MetricsClient contains the methods for the Metrics group. +// Don't use this type directly, use NewMetricsClient() instead. +type MetricsClient struct { + con *armcore.Connection +} + +// NewMetricsClient creates a new instance of MetricsClient with the specified values. +func NewMetricsClient(con *armcore.Connection) *MetricsClient { + return &MetricsClient{con: con} +} + +// List - Lists the metric values for a resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *MetricsClient) List(ctx context.Context, resourceURI string, options *MetricsListOptions) (ResponseResponse, error) { + req, err := client.listCreateRequest(ctx, resourceURI, options) + if err != nil { + return ResponseResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ResponseResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ResponseResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *MetricsClient) listCreateRequest(ctx context.Context, resourceURI string, options *MetricsListOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/metrics" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Timespan != nil { + reqQP.Set("timespan", *options.Timespan) + } + if options != nil && options.Interval != nil { + reqQP.Set("interval", *options.Interval) + } + if options != nil && options.Metricnames != nil { + reqQP.Set("metricnames", *options.Metricnames) + } + if options != nil && options.Aggregation != nil { + reqQP.Set("aggregation", *options.Aggregation) + } + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Orderby != nil { + reqQP.Set("orderby", *options.Orderby) + } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.ResultType != nil { + reqQP.Set("resultType", string(*options.ResultType)) + } + reqQP.Set("api-version", "2018-01-01") + if options != nil && options.Metricnamespace != nil { + reqQP.Set("metricnamespace", *options.Metricnamespace) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *MetricsClient) listHandleResponse(resp *azcore.Response) (ResponseResponse, error) { + var val *Response + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ResponseResponse{}, err + } + return ResponseResponse{RawResponse: resp.Response, Response: val}, nil +} + +// listHandleError handles the List error response. +func (client *MetricsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_models.go b/sdk/monitor/armmonitor/zz_generated_models.go new file mode 100644 index 000000000000..5c269297c4fc --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_models.go @@ -0,0 +1,5551 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// ActionClassification provides polymorphic access to related types. +// Call the interface's GetAction() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *Action, *AlertingAction, *LogToMetricAction +type ActionClassification interface { + // GetAction returns the Action content of the underlying type. + GetAction() *Action +} + +// Action descriptor. +type Action struct { + // REQUIRED; Specifies the action. Supported values - AlertingAction, LogToMetricAction + OdataType *string `json:"odata.type,omitempty"` +} + +// GetAction implements the ActionClassification interface for type Action. +func (a *Action) GetAction() *Action { return a } + +// UnmarshalJSON implements the json.Unmarshaller interface for type Action. +func (a *Action) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return a.unmarshalInternal(rawMsg) +} + +func (a Action) marshalInternal(discValue string) map[string]interface{} { + objectMap := make(map[string]interface{}) + a.OdataType = &discValue + objectMap["odata.type"] = a.OdataType + return objectMap +} + +func (a *Action) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "odata.type": + err = unpopulate(val, &a.OdataType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ActionGroup - An Azure action group. +type ActionGroup struct { + // REQUIRED; 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"` + + // REQUIRED; The short name of the action group. This will be used in SMS messages. + GroupShortName *string `json:"groupShortName,omitempty"` + + // 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"` + + // The list of AutomationRunbook receivers that are part of this action group. + AutomationRunbookReceivers []*AutomationRunbookReceiver `json:"automationRunbookReceivers,omitempty"` + + // The list of AzureAppPush receivers that are part of this action group. + AzureAppPushReceivers []*AzureAppPushReceiver `json:"azureAppPushReceivers,omitempty"` + + // The list of azure function receivers that are part of this action group. + AzureFunctionReceivers []*AzureFunctionReceiver `json:"azureFunctionReceivers,omitempty"` + + // The list of email receivers that are part of this action group. + EmailReceivers []*EmailReceiver `json:"emailReceivers,omitempty"` + + // The list of ITSM receivers that are part of this action group. + ItsmReceivers []*ItsmReceiver `json:"itsmReceivers,omitempty"` + + // The list of logic app receivers that are part of this action group. + LogicAppReceivers []*LogicAppReceiver `json:"logicAppReceivers,omitempty"` + + // The list of SMS receivers that are part of this action group. + SmsReceivers []*SmsReceiver `json:"smsReceivers,omitempty"` + + // The list of voice receivers that are part of this action group. + VoiceReceivers []*VoiceReceiver `json:"voiceReceivers,omitempty"` + + // The list of webhook receivers that are part of this action group. + WebhookReceivers []*WebhookReceiver `json:"webhookReceivers,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActionGroup. +func (a ActionGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "armRoleReceivers", a.ArmRoleReceivers) + populate(objectMap, "automationRunbookReceivers", a.AutomationRunbookReceivers) + populate(objectMap, "azureAppPushReceivers", a.AzureAppPushReceivers) + populate(objectMap, "azureFunctionReceivers", a.AzureFunctionReceivers) + populate(objectMap, "emailReceivers", a.EmailReceivers) + populate(objectMap, "enabled", a.Enabled) + populate(objectMap, "groupShortName", a.GroupShortName) + populate(objectMap, "itsmReceivers", a.ItsmReceivers) + populate(objectMap, "logicAppReceivers", a.LogicAppReceivers) + populate(objectMap, "smsReceivers", a.SmsReceivers) + populate(objectMap, "voiceReceivers", a.VoiceReceivers) + populate(objectMap, "webhookReceivers", a.WebhookReceivers) + return json.Marshal(objectMap) +} + +// ActionGroupList - A list of action groups. +type ActionGroupList struct { + // Provides the link to retrieve the next set of elements. + NextLink *string `json:"nextLink,omitempty"` + + // The list of action groups. + Value []*ActionGroupResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActionGroupList. +func (a ActionGroupList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// ActionGroupPatch - An Azure action group for patch operations. +type ActionGroupPatch struct { + // 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 { + // The action group settings for an update operation. + Properties *ActionGroupPatch `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActionGroupPatchBody. +func (a ActionGroupPatchBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// ActionGroupResource - An action group resource. +type ActionGroupResource struct { + AzureResource + // The action groups properties of the resource. + Properties *ActionGroup `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActionGroupResource. +func (a ActionGroupResource) MarshalJSON() ([]byte, error) { + objectMap := a.AzureResource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// ActionGroupsCreateOrUpdateOptions contains the optional parameters for the ActionGroups.CreateOrUpdate method. +type ActionGroupsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ActionGroupsDeleteOptions contains the optional parameters for the ActionGroups.Delete method. +type ActionGroupsDeleteOptions struct { + // placeholder for future optional parameters +} + +// ActionGroupsEnableReceiverOptions contains the optional parameters for the ActionGroups.EnableReceiver method. +type ActionGroupsEnableReceiverOptions struct { + // placeholder for future optional parameters +} + +// ActionGroupsGetOptions contains the optional parameters for the ActionGroups.Get method. +type ActionGroupsGetOptions struct { + // placeholder for future optional parameters +} + +// ActionGroupsListByResourceGroupOptions contains the optional parameters for the ActionGroups.ListByResourceGroup method. +type ActionGroupsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ActionGroupsListBySubscriptionIDOptions contains the optional parameters for the ActionGroups.ListBySubscriptionID method. +type ActionGroupsListBySubscriptionIDOptions struct { + // placeholder for future optional parameters +} + +// ActionGroupsUpdateOptions contains the optional parameters for the ActionGroups.Update method. +type ActionGroupsUpdateOptions struct { + // placeholder for future optional parameters +} + +// ActivityLogAlert - An Azure activity log alert. +type ActivityLogAlert struct { + // REQUIRED; The actions that will activate when the condition is met. + Actions *ActivityLogAlertActionList `json:"actions,omitempty"` + + // REQUIRED; The condition that will cause this alert to activate. + Condition *ActivityLogAlertAllOfCondition `json:"condition,omitempty"` + + // REQUIRED; 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"` + + // A description of this activity log alert. + Description *string `json:"description,omitempty"` + + // 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActivityLogAlert. +func (a ActivityLogAlert) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actions", a.Actions) + populate(objectMap, "condition", a.Condition) + populate(objectMap, "description", a.Description) + populate(objectMap, "enabled", a.Enabled) + populate(objectMap, "scopes", a.Scopes) + return json.Marshal(objectMap) +} + +// ActivityLogAlertActionGroup - A pointer to an Azure Action Group. +type ActivityLogAlertActionGroup struct { + // REQUIRED; The resourceId of the action group. This cannot be null or empty. + ActionGroupID *string `json:"actionGroupId,omitempty"` + + // 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,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActivityLogAlertActionGroup. +func (a ActivityLogAlertActionGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionGroupId", a.ActionGroupID) + populate(objectMap, "webhookProperties", a.WebhookProperties) + return json.Marshal(objectMap) +} + +// ActivityLogAlertActionList - A list of activity log alert actions. +type ActivityLogAlertActionList struct { + // The list of activity log alerts. + ActionGroups []*ActivityLogAlertActionGroup `json:"actionGroups,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActivityLogAlertActionList. +func (a ActivityLogAlertActionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionGroups", a.ActionGroups) + return json.Marshal(objectMap) +} + +// ActivityLogAlertAllOfCondition - An Activity Log alert condition that is met when all its member conditions are met. +type ActivityLogAlertAllOfCondition struct { + // REQUIRED; The list of activity log alert conditions. + AllOf []*ActivityLogAlertLeafCondition `json:"allOf,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActivityLogAlertAllOfCondition. +func (a ActivityLogAlertAllOfCondition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "allOf", a.AllOf) + return json.Marshal(objectMap) +} + +// ActivityLogAlertLeafCondition - An Activity Log alert condition that is met by comparing an activity log field and value. +type ActivityLogAlertLeafCondition struct { + // REQUIRED; The field value will be compared to this value (case-insensitive) to determine if the condition is met. + Equals *string `json:"equals,omitempty"` + + // REQUIRED; 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"` +} + +// ActivityLogAlertList - A list of activity log alerts. +type ActivityLogAlertList struct { + // Provides the link to retrieve the next set of elements. + NextLink *string `json:"nextLink,omitempty"` + + // The list of activity log alerts. + Value []*ActivityLogAlertResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActivityLogAlertList. +func (a ActivityLogAlertList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// ActivityLogAlertPatch - An Azure activity log alert for patch operations. +type ActivityLogAlertPatch struct { + // 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 { + // The activity log alert settings for an update operation. + Properties *ActivityLogAlertPatch `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActivityLogAlertPatchBody. +func (a ActivityLogAlertPatchBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// ActivityLogAlertResource - An activity log alert resource. +type ActivityLogAlertResource struct { + Resource + // The activity log alert properties of the resource. + Properties *ActivityLogAlert `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ActivityLogAlertResource. +func (a ActivityLogAlertResource) MarshalJSON() ([]byte, error) { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// ActivityLogAlertsCreateOrUpdateOptions contains the optional parameters for the ActivityLogAlerts.CreateOrUpdate method. +type ActivityLogAlertsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ActivityLogAlertsDeleteOptions contains the optional parameters for the ActivityLogAlerts.Delete method. +type ActivityLogAlertsDeleteOptions struct { + // placeholder for future optional parameters +} + +// ActivityLogAlertsGetOptions contains the optional parameters for the ActivityLogAlerts.Get method. +type ActivityLogAlertsGetOptions struct { + // placeholder for future optional parameters +} + +// ActivityLogAlertsListByResourceGroupOptions contains the optional parameters for the ActivityLogAlerts.ListByResourceGroup method. +type ActivityLogAlertsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ActivityLogAlertsListBySubscriptionIDOptions contains the optional parameters for the ActivityLogAlerts.ListBySubscriptionID method. +type ActivityLogAlertsListBySubscriptionIDOptions struct { + // placeholder for future optional parameters +} + +// ActivityLogAlertsUpdateOptions contains the optional parameters for the ActivityLogAlerts.Update method. +type ActivityLogAlertsUpdateOptions struct { + // placeholder for future optional parameters +} + +// ActivityLogsListOptions contains the optional parameters for the ActivityLogs.List method. +type ActivityLogsListOptions struct { + // 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* + Select *string +} + +// AlertRule - An alert rule. +type AlertRule struct { + // REQUIRED; the condition that results in the alert rule being activated. + Condition RuleConditionClassification `json:"condition,omitempty"` + + // REQUIRED; the flag that indicates whether the alert rule is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` + + // REQUIRED; the name of the alert rule. + Name *string `json:"name,omitempty"` + + // action that is performed when the alert rule becomes active, and when an alert condition is resolved. + Action RuleActionClassification `json:"action,omitempty"` + + // the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + Actions []RuleActionClassification `json:"actions,omitempty"` + + // the description of the alert rule that will be included in the alert email. + Description *string `json:"description,omitempty"` + + // the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty"` + + // READ-ONLY; Last time the rule was updated in ISO8601 format. + LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AlertRule. +func (a AlertRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "action", a.Action) + populate(objectMap, "actions", a.Actions) + populate(objectMap, "condition", a.Condition) + populate(objectMap, "description", a.Description) + populate(objectMap, "isEnabled", a.IsEnabled) + populate(objectMap, "lastUpdatedTime", (*timeRFC3339)(a.LastUpdatedTime)) + populate(objectMap, "name", a.Name) + populate(objectMap, "provisioningState", a.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertRule. +func (a *AlertRule) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + a.Action, err = unmarshalRuleActionClassification(val) + delete(rawMsg, key) + case "actions": + a.Actions, err = unmarshalRuleActionClassificationArray(val) + delete(rawMsg, key) + case "condition": + a.Condition, err = unmarshalRuleConditionClassification(val) + delete(rawMsg, key) + case "description": + err = unpopulate(val, &a.Description) + delete(rawMsg, key) + case "isEnabled": + err = unpopulate(val, &a.IsEnabled) + delete(rawMsg, key) + case "lastUpdatedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.LastUpdatedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &a.Name) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &a.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// AlertRuleIncidentsGetOptions contains the optional parameters for the AlertRuleIncidents.Get method. +type AlertRuleIncidentsGetOptions struct { + // placeholder for future optional parameters +} + +// AlertRuleIncidentsListByAlertRuleOptions contains the optional parameters for the AlertRuleIncidents.ListByAlertRule method. +type AlertRuleIncidentsListByAlertRuleOptions struct { + // placeholder for future optional parameters +} + +// AlertRuleResource - The alert rule resource. +type AlertRuleResource struct { + Resource + // REQUIRED; The alert rule properties of the resource. + Properties *AlertRule `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AlertRuleResource. +func (a AlertRuleResource) MarshalJSON() ([]byte, error) { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// AlertRuleResourceCollection - Represents a collection of alert rule resources. +type AlertRuleResourceCollection struct { + // the values for the alert rule resources. + Value []*AlertRuleResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AlertRuleResourceCollection. +func (a AlertRuleResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AlertRuleResourcePatch - The alert rule object for patch operations. +type AlertRuleResourcePatch struct { + // The properties of an alert rule. + Properties *AlertRule `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AlertRuleResourcePatch. +func (a AlertRuleResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// AlertRulesCreateOrUpdateOptions contains the optional parameters for the AlertRules.CreateOrUpdate method. +type AlertRulesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// AlertRulesDeleteOptions contains the optional parameters for the AlertRules.Delete method. +type AlertRulesDeleteOptions struct { + // placeholder for future optional parameters +} + +// AlertRulesGetOptions contains the optional parameters for the AlertRules.Get method. +type AlertRulesGetOptions struct { + // placeholder for future optional parameters +} + +// AlertRulesListByResourceGroupOptions contains the optional parameters for the AlertRules.ListByResourceGroup method. +type AlertRulesListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// AlertRulesListBySubscriptionOptions contains the optional parameters for the AlertRules.ListBySubscription method. +type AlertRulesListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// AlertRulesUpdateOptions contains the optional parameters for the AlertRules.Update method. +type AlertRulesUpdateOptions struct { + // placeholder for future optional parameters +} + +// AlertingAction - Specify action need to be taken when rule type is Alert +type AlertingAction struct { + Action + // REQUIRED; Severity of the alert + Severity *AlertSeverity `json:"severity,omitempty"` + + // REQUIRED; The trigger condition that results in the alert rule being. + Trigger *TriggerCondition `json:"trigger,omitempty"` + + // Azure action group reference. + AznsAction *AzNsActionGroup `json:"aznsAction,omitempty"` + + // time (in minutes) for which Alerts should be throttled or suppressed. + ThrottlingInMin *int32 `json:"throttlingInMin,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AlertingAction. +func (a AlertingAction) MarshalJSON() ([]byte, error) { + objectMap := a.Action.marshalInternal("Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction") + populate(objectMap, "aznsAction", a.AznsAction) + populate(objectMap, "severity", a.Severity) + populate(objectMap, "throttlingInMin", a.ThrottlingInMin) + populate(objectMap, "trigger", a.Trigger) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertingAction. +func (a *AlertingAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "aznsAction": + err = unpopulate(val, &a.AznsAction) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, &a.Severity) + delete(rawMsg, key) + case "throttlingInMin": + err = unpopulate(val, &a.ThrottlingInMin) + delete(rawMsg, key) + case "trigger": + err = unpopulate(val, &a.Trigger) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return a.Action.unmarshalInternal(rawMsg) +} + +// ArmRoleReceiver - An arm role receiver. +type ArmRoleReceiver struct { + // REQUIRED; The name of the arm role receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + + // REQUIRED; The arm role id. + RoleID *string `json:"roleId,omitempty"` + + // Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// AutomationRunbookReceiver - The Azure Automation Runbook notification receiver. +type AutomationRunbookReceiver struct { + // REQUIRED; The Azure automation account Id which holds this runbook and authenticate to Azure resource. + AutomationAccountID *string `json:"automationAccountId,omitempty"` + + // REQUIRED; Indicates whether this instance is global runbook. + IsGlobalRunbook *bool `json:"isGlobalRunbook,omitempty"` + + // REQUIRED; The name for this runbook. + RunbookName *string `json:"runbookName,omitempty"` + + // REQUIRED; The resource id for webhook linked to this runbook. + WebhookResourceID *string `json:"webhookResourceId,omitempty"` + + // Indicates name of the webhook. + Name *string `json:"name,omitempty"` + + // The URI where webhooks should be sent. + ServiceURI *string `json:"serviceUri,omitempty"` + + // Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// AutoscaleNotification - Autoscale notification. +type AutoscaleNotification struct { + // REQUIRED; the operation associated with the notification and its value must be "scale" + Operation *string `json:"operation,omitempty"` + + // the email notification. + Email *EmailNotification `json:"email,omitempty"` + + // the collection of webhook notifications. + Webhooks []*WebhookNotification `json:"webhooks,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AutoscaleNotification. +func (a AutoscaleNotification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "email", a.Email) + populate(objectMap, "operation", a.Operation) + populate(objectMap, "webhooks", a.Webhooks) + return json.Marshal(objectMap) +} + +// AutoscaleProfile - Autoscale profile. +type AutoscaleProfile struct { + // REQUIRED; the number of instances that can be used during this profile. + Capacity *ScaleCapacity `json:"capacity,omitempty"` + + // REQUIRED; the name of the profile. + Name *string `json:"name,omitempty"` + + // REQUIRED; 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"` + + // the specific date-time for the profile. This element is not used if the Recurrence element is used. + FixedDate *TimeWindow `json:"fixedDate,omitempty"` + + // the repeating times at which this profile begins. This element is not used if the FixedDate element is used. + Recurrence *Recurrence `json:"recurrence,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AutoscaleProfile. +func (a AutoscaleProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "capacity", a.Capacity) + populate(objectMap, "fixedDate", a.FixedDate) + populate(objectMap, "name", a.Name) + populate(objectMap, "recurrence", a.Recurrence) + populate(objectMap, "rules", a.Rules) + return json.Marshal(objectMap) +} + +// AutoscaleSetting - A setting that contains all of the configuration for the automatic scaling of a resource. +type AutoscaleSetting struct { + // REQUIRED; 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"` + + // the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. + Enabled *bool `json:"enabled,omitempty"` + + // the name of the autoscale setting. + Name *string `json:"name,omitempty"` + + // the collection of notifications. + Notifications []*AutoscaleNotification `json:"notifications,omitempty"` + + // the location of the resource that the autoscale setting should be added to. + TargetResourceLocation *string `json:"targetResourceLocation,omitempty"` + + // the resource identifier of the resource that the autoscale setting should be added to. + TargetResourceURI *string `json:"targetResourceUri,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AutoscaleSetting. +func (a AutoscaleSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "enabled", a.Enabled) + populate(objectMap, "name", a.Name) + populate(objectMap, "notifications", a.Notifications) + populate(objectMap, "profiles", a.Profiles) + populate(objectMap, "targetResourceLocation", a.TargetResourceLocation) + populate(objectMap, "targetResourceUri", a.TargetResourceURI) + return json.Marshal(objectMap) +} + +// AutoscaleSettingResource - The autoscale setting resource. +type AutoscaleSettingResource struct { + Resource + // REQUIRED; The autoscale setting of the resource. + Properties *AutoscaleSetting `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AutoscaleSettingResource. +func (a AutoscaleSettingResource) MarshalJSON() ([]byte, error) { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// AutoscaleSettingResourceCollection - Represents a collection of autoscale setting resources. +type AutoscaleSettingResourceCollection struct { + // REQUIRED; the values for the autoscale setting resources. + Value []*AutoscaleSettingResource `json:"value,omitempty"` + + // URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AutoscaleSettingResourceCollection. +func (a AutoscaleSettingResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AutoscaleSettingResourcePatch - The autoscale setting object for patch operations. +type AutoscaleSettingResourcePatch struct { + // The autoscale setting properties of the update operation. + Properties *AutoscaleSetting `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AutoscaleSettingResourcePatch. +func (a AutoscaleSettingResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// AutoscaleSettingsCreateOrUpdateOptions contains the optional parameters for the AutoscaleSettings.CreateOrUpdate method. +type AutoscaleSettingsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// AutoscaleSettingsDeleteOptions contains the optional parameters for the AutoscaleSettings.Delete method. +type AutoscaleSettingsDeleteOptions struct { + // placeholder for future optional parameters +} + +// AutoscaleSettingsGetOptions contains the optional parameters for the AutoscaleSettings.Get method. +type AutoscaleSettingsGetOptions struct { + // placeholder for future optional parameters +} + +// AutoscaleSettingsListByResourceGroupOptions contains the optional parameters for the AutoscaleSettings.ListByResourceGroup method. +type AutoscaleSettingsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// AutoscaleSettingsListBySubscriptionOptions contains the optional parameters for the AutoscaleSettings.ListBySubscription method. +type AutoscaleSettingsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// AutoscaleSettingsUpdateOptions contains the optional parameters for the AutoscaleSettings.Update method. +type AutoscaleSettingsUpdateOptions struct { + // placeholder for future optional parameters +} + +// AzNsActionGroup - Azure action group +type AzNsActionGroup struct { + // Azure Action Group reference. + ActionGroup []*string `json:"actionGroup,omitempty"` + + // Custom payload to be sent for all webhook URI in Azure action group + CustomWebhookPayload *string `json:"customWebhookPayload,omitempty"` + + // Custom subject override for all email ids in Azure action group + EmailSubject *string `json:"emailSubject,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AzNsActionGroup. +func (a AzNsActionGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionGroup", a.ActionGroup) + populate(objectMap, "customWebhookPayload", a.CustomWebhookPayload) + populate(objectMap, "emailSubject", a.EmailSubject) + return json.Marshal(objectMap) +} + +// AzureAppPushReceiver - The Azure mobile App push notification receiver. +type AzureAppPushReceiver struct { + // REQUIRED; The email address registered for the Azure mobile app. + EmailAddress *string `json:"emailAddress,omitempty"` + + // REQUIRED; 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"` +} + +// AzureFunctionReceiver - An azure function receiver. +type AzureFunctionReceiver struct { + // REQUIRED; The azure resource id of the function app. + FunctionAppResourceID *string `json:"functionAppResourceId,omitempty"` + + // REQUIRED; The function name in the function app. + FunctionName *string `json:"functionName,omitempty"` + + // REQUIRED; The http trigger url where http request sent to. + HTTPTriggerURL *string `json:"httpTriggerUrl,omitempty"` + + // REQUIRED; The name of the azure function receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + + // Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// AzureMonitorMetricsDestination - Azure Monitor Metrics destination. +type AzureMonitorMetricsDestination struct { + // 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 { + PrivateLinkScopesResource + // REQUIRED; Properties that define a Azure Monitor PrivateLinkScope resource. + Properties *AzureMonitorPrivateLinkScopeProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AzureMonitorPrivateLinkScope. +func (a AzureMonitorPrivateLinkScope) MarshalJSON() ([]byte, error) { + objectMap := a.PrivateLinkScopesResource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// AzureMonitorPrivateLinkScopeListResult - Describes the list of Azure Monitor PrivateLinkScope resources. +type AzureMonitorPrivateLinkScopeListResult struct { + // REQUIRED; List of Azure Monitor PrivateLinkScope definitions. + Value []*AzureMonitorPrivateLinkScope `json:"value,omitempty"` + + // 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type AzureMonitorPrivateLinkScopeListResult. +func (a AzureMonitorPrivateLinkScopeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AzureMonitorPrivateLinkScopeProperties - Properties that define a Azure Monitor PrivateLinkScope resource. +type AzureMonitorPrivateLinkScopeProperties struct { + // READ-ONLY; List of private endpoint connections. + PrivateEndpointConnections []*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty" azure:"ro"` + + // 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" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AzureMonitorPrivateLinkScopeProperties. +func (a AzureMonitorPrivateLinkScopeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "privateEndpointConnections", a.PrivateEndpointConnections) + populate(objectMap, "provisioningState", a.ProvisioningState) + return json.Marshal(objectMap) +} + +// AzureResource - An azure resource object +type AzureResource struct { + // REQUIRED; Resource location + Location *string `json:"location,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource identity + Identity *string `json:"identity,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource kind + Kind *string `json:"kind,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AzureResource. +func (a AzureResource) MarshalJSON() ([]byte, error) { + objectMap := a.marshalInternal() + return json.Marshal(objectMap) +} + +func (a AzureResource) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "identity", a.Identity) + populate(objectMap, "kind", a.Kind) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return objectMap +} + +// BaselineMetadata - Represents a baseline metadata value. +type BaselineMetadata struct { + // REQUIRED; Name of the baseline metadata. + Name *string `json:"name,omitempty"` + + // REQUIRED; Value of the baseline metadata. + Value *string `json:"value,omitempty"` +} + +// BaselinesListOptions contains the optional parameters for the Baselines.List method. +type BaselinesListOptions struct { + // The list of aggregation types (comma separated) to retrieve. + Aggregation *string + // 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' "** + Filter *string + // The interval (i.e. timegrain) of the query. + Interval *string + // 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'** + Metricnames *string + // Metric namespace to query metric definitions for. + Metricnamespace *string + // Allows retrieving only metadata of the baseline. On data request all information is retrieved. + ResultType *ResultType + // The list of sensitivities (comma separated) to retrieve. + Sensitivities *string + // The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + Timespan *string +} + +// ConfigurationAccessEndpointSpec - Definition of the endpoint used for accessing configuration. +type ConfigurationAccessEndpointSpec struct { + // READ-ONLY; The endpoint. This property is READ-ONLY. + Endpoint *string `json:"endpoint,omitempty" azure:"ro"` +} + +// Criteria - Specifies the criteria for converting log to metric. +type Criteria struct { + // REQUIRED; Name of the metric + MetricName *string `json:"metricName,omitempty"` + + // List of Dimensions for creating metric + Dimensions []*Dimension `json:"dimensions,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Criteria. +func (c Criteria) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dimensions", c.Dimensions) + populate(objectMap, "metricName", c.MetricName) + return json.Marshal(objectMap) +} + +// DataCollectionEndpoint - Definition of data collection endpoint. +type DataCollectionEndpoint struct { + // The endpoint used by agents to access their configuration. + ConfigurationAccess *DataCollectionEndpointConfigurationAccess `json:"configurationAccess,omitempty"` + + // Description of the data collection endpoint. + Description *string `json:"description,omitempty"` + + // The immutable ID of this data collection endpoint resource. This property is READ-ONLY. + ImmutableID *string `json:"immutableId,omitempty"` + + // The endpoint used by clients to ingest logs. + LogsIngestion *DataCollectionEndpointLogsIngestion `json:"logsIngestion,omitempty"` + + // Network access control rules for the endpoints. + NetworkACLs *DataCollectionEndpointNetworkACLs `json:"networkAcls,omitempty"` + + // READ-ONLY; The resource provisioning state. This property is READ-ONLY. + ProvisioningState *KnownDataCollectionEndpointProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// DataCollectionEndpointConfigurationAccess - The endpoint used by agents to access their configuration. +type DataCollectionEndpointConfigurationAccess struct { + ConfigurationAccessEndpointSpec +} + +// DataCollectionEndpointLogsIngestion - The endpoint used by clients to ingest logs. +type DataCollectionEndpointLogsIngestion struct { + LogsIngestionEndpointSpec +} + +// DataCollectionEndpointNetworkACLs - Network access control rules for the endpoints. +type DataCollectionEndpointNetworkACLs struct { + NetworkRuleSet +} + +// DataCollectionEndpointResource - Definition of ARM tracked top level resource. +type DataCollectionEndpointResource struct { + // REQUIRED; The geo-location where the resource lives. + Location *string `json:"location,omitempty"` + + // The kind of the resource. + Kind *KnownDataCollectionEndpointResourceKind `json:"kind,omitempty"` + + // Resource properties. + Properties *DataCollectionEndpointResourceProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource entity tag (ETag). + Etag *string `json:"etag,omitempty" azure:"ro"` + + // READ-ONLY; Fully qualified ID of the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *DataCollectionEndpointResourceSystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataCollectionEndpointResource. +func (d DataCollectionEndpointResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "etag", d.Etag) + populate(objectMap, "id", d.ID) + populate(objectMap, "kind", d.Kind) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// DataCollectionEndpointResourceListResult - A pageable list of resources. +type DataCollectionEndpointResourceListResult struct { + // REQUIRED; A list of resources. + Value []*DataCollectionEndpointResource `json:"value,omitempty"` + + // The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataCollectionEndpointResourceListResult. +func (d DataCollectionEndpointResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DataCollectionEndpointResourceProperties - Resource properties. +type DataCollectionEndpointResourceProperties struct { + DataCollectionEndpoint +} + +// DataCollectionEndpointResourceSystemData - Metadata pertaining to creation and last modification of the resource. +type DataCollectionEndpointResourceSystemData struct { + SystemData +} + +// DataCollectionEndpointsCreateOptions contains the optional parameters for the DataCollectionEndpoints.Create method. +type DataCollectionEndpointsCreateOptions struct { + // The payload + Body *DataCollectionEndpointResource +} + +// DataCollectionEndpointsDeleteOptions contains the optional parameters for the DataCollectionEndpoints.Delete method. +type DataCollectionEndpointsDeleteOptions struct { + // placeholder for future optional parameters +} + +// DataCollectionEndpointsGetOptions contains the optional parameters for the DataCollectionEndpoints.Get method. +type DataCollectionEndpointsGetOptions struct { + // placeholder for future optional parameters +} + +// DataCollectionEndpointsListByResourceGroupOptions contains the optional parameters for the DataCollectionEndpoints.ListByResourceGroup method. +type DataCollectionEndpointsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// DataCollectionEndpointsListBySubscriptionOptions contains the optional parameters for the DataCollectionEndpoints.ListBySubscription method. +type DataCollectionEndpointsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// DataCollectionEndpointsUpdateOptions contains the optional parameters for the DataCollectionEndpoints.Update method. +type DataCollectionEndpointsUpdateOptions struct { + // The payload + Body *ResourceForUpdate +} + +// DataCollectionRule - Definition of what monitoring data to collect and where that data should be sent. +type DataCollectionRule struct { + // The specification of data flows. + DataFlows []*DataFlow `json:"dataFlows,omitempty"` + + // 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"` + + // Description of the data collection rule. + Description *string `json:"description,omitempty"` + + // The specification of destinations. + Destinations *DataCollectionRuleDestinations `json:"destinations,omitempty"` + + // READ-ONLY; The immutable ID of this data collection rule. This property is READ-ONLY. + ImmutableID *string `json:"immutableId,omitempty" azure:"ro"` + + // READ-ONLY; The resource provisioning state. + ProvisioningState *KnownDataCollectionRuleProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataCollectionRule. +func (d DataCollectionRule) MarshalJSON() ([]byte, error) { + objectMap := d.marshalInternal() + return json.Marshal(objectMap) +} + +func (d DataCollectionRule) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "dataFlows", d.DataFlows) + populate(objectMap, "dataSources", d.DataSources) + populate(objectMap, "description", d.Description) + populate(objectMap, "destinations", d.Destinations) + populate(objectMap, "immutableId", d.ImmutableID) + populate(objectMap, "provisioningState", d.ProvisioningState) + return objectMap +} + +// DataCollectionRuleAssociation - Definition of association of a data collection rule with a monitored Azure resource. +type DataCollectionRuleAssociation struct { + // The resource ID of the data collection endpoint that is to be associated. + DataCollectionEndpointID *string `json:"dataCollectionEndpointId,omitempty"` + + // The resource ID of the data collection rule that is to be associated. + DataCollectionRuleID *string `json:"dataCollectionRuleId,omitempty"` + + // Description of the association. + Description *string `json:"description,omitempty"` + + // READ-ONLY; The resource provisioning state. + ProvisioningState *KnownDataCollectionRuleAssociationProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// DataCollectionRuleAssociationProxyOnlyResource - Definition of generic ARM proxy resource. +type DataCollectionRuleAssociationProxyOnlyResource struct { + // Resource properties. + Properties *DataCollectionRuleAssociationProxyOnlyResourceProperties `json:"properties,omitempty"` + + // READ-ONLY; Resource entity tag (ETag). + Etag *string `json:"etag,omitempty" azure:"ro"` + + // READ-ONLY; Fully qualified ID of the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *DataCollectionRuleAssociationProxyOnlyResourceSystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// DataCollectionRuleAssociationProxyOnlyResourceListResult - A pageable list of resources. +type DataCollectionRuleAssociationProxyOnlyResourceListResult struct { + // REQUIRED; A list of resources. + Value []*DataCollectionRuleAssociationProxyOnlyResource `json:"value,omitempty"` + + // The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataCollectionRuleAssociationProxyOnlyResourceListResult. +func (d DataCollectionRuleAssociationProxyOnlyResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DataCollectionRuleAssociationProxyOnlyResourceProperties - Resource properties. +type DataCollectionRuleAssociationProxyOnlyResourceProperties struct { + DataCollectionRuleAssociation +} + +// DataCollectionRuleAssociationProxyOnlyResourceSystemData - Metadata pertaining to creation and last modification of the resource. +type DataCollectionRuleAssociationProxyOnlyResourceSystemData struct { + SystemData +} + +// DataCollectionRuleAssociationsCreateOptions contains the optional parameters for the DataCollectionRuleAssociations.Create method. +type DataCollectionRuleAssociationsCreateOptions struct { + // The payload + Body *DataCollectionRuleAssociationProxyOnlyResource +} + +// DataCollectionRuleAssociationsDeleteOptions contains the optional parameters for the DataCollectionRuleAssociations.Delete method. +type DataCollectionRuleAssociationsDeleteOptions struct { + // placeholder for future optional parameters +} + +// DataCollectionRuleAssociationsGetOptions contains the optional parameters for the DataCollectionRuleAssociations.Get method. +type DataCollectionRuleAssociationsGetOptions struct { + // placeholder for future optional parameters +} + +// DataCollectionRuleAssociationsListByResourceOptions contains the optional parameters for the DataCollectionRuleAssociations.ListByResource method. +type DataCollectionRuleAssociationsListByResourceOptions struct { + // placeholder for future optional parameters +} + +// DataCollectionRuleAssociationsListByRuleOptions contains the optional parameters for the DataCollectionRuleAssociations.ListByRule method. +type DataCollectionRuleAssociationsListByRuleOptions struct { + // placeholder for future optional parameters +} + +// 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 { + DataSourcesSpec +} + +// DataCollectionRuleDestinations - The specification of destinations. +type DataCollectionRuleDestinations struct { + DestinationsSpec +} + +// DataCollectionRuleResource - Definition of ARM tracked top level resource. +type DataCollectionRuleResource struct { + // REQUIRED; The geo-location where the resource lives. + Location *string `json:"location,omitempty"` + + // The kind of the resource. + Kind *KnownDataCollectionRuleResourceKind `json:"kind,omitempty"` + + // Resource properties. + Properties *DataCollectionRuleResourceProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource entity tag (ETag). + Etag *string `json:"etag,omitempty" azure:"ro"` + + // READ-ONLY; Fully qualified ID of the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *DataCollectionRuleResourceSystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataCollectionRuleResource. +func (d DataCollectionRuleResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "etag", d.Etag) + populate(objectMap, "id", d.ID) + populate(objectMap, "kind", d.Kind) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// DataCollectionRuleResourceListResult - A pageable list of resources. +type DataCollectionRuleResourceListResult struct { + // REQUIRED; A list of resources. + Value []*DataCollectionRuleResource `json:"value,omitempty"` + + // The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataCollectionRuleResourceListResult. +func (d DataCollectionRuleResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DataCollectionRuleResourceProperties - Resource properties. +type DataCollectionRuleResourceProperties struct { + DataCollectionRule +} + +// DataCollectionRuleResourceSystemData - Metadata pertaining to creation and last modification of the resource. +type DataCollectionRuleResourceSystemData struct { + SystemData +} + +// DataCollectionRulesCreateOptions contains the optional parameters for the DataCollectionRules.Create method. +type DataCollectionRulesCreateOptions struct { + // The payload + Body *DataCollectionRuleResource +} + +// DataCollectionRulesDeleteOptions contains the optional parameters for the DataCollectionRules.Delete method. +type DataCollectionRulesDeleteOptions struct { + // placeholder for future optional parameters +} + +// DataCollectionRulesGetOptions contains the optional parameters for the DataCollectionRules.Get method. +type DataCollectionRulesGetOptions struct { + // placeholder for future optional parameters +} + +// DataCollectionRulesListByResourceGroupOptions contains the optional parameters for the DataCollectionRules.ListByResourceGroup method. +type DataCollectionRulesListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// DataCollectionRulesListBySubscriptionOptions contains the optional parameters for the DataCollectionRules.ListBySubscription method. +type DataCollectionRulesListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// DataCollectionRulesUpdateOptions contains the optional parameters for the DataCollectionRules.Update method. +type DataCollectionRulesUpdateOptions struct { + // The payload + Body *ResourceForUpdate +} + +// DataContainer - Information about a container with data for a given resource. +type DataContainer struct { + // REQUIRED; Log Analytics workspace information. + Workspace *WorkspaceInfo `json:"workspace,omitempty"` +} + +// DataFlow - Definition of which streams are sent to which destinations. +type DataFlow struct { + // List of destinations for this data flow. + Destinations []*string `json:"destinations,omitempty"` + + // List of streams for this data flow. + Streams []*KnownDataFlowStreams `json:"streams,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataFlow. +func (d DataFlow) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "destinations", d.Destinations) + populate(objectMap, "streams", d.Streams) + return json.Marshal(objectMap) +} + +// DataSourcesSpec - Specification of data sources that will be collected. +type DataSourcesSpec struct { + // The list of Azure VM extension data source configurations. + Extensions []*ExtensionDataSource `json:"extensions,omitempty"` + + // The list of performance counter data source configurations. + PerformanceCounters []*PerfCounterDataSource `json:"performanceCounters,omitempty"` + + // The list of Syslog data source configurations. + Syslog []*SyslogDataSource `json:"syslog,omitempty"` + + // The list of Windows Event Log data source configurations. + WindowsEventLogs []*WindowsEventLogDataSource `json:"windowsEventLogs,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataSourcesSpec. +func (d DataSourcesSpec) MarshalJSON() ([]byte, error) { + objectMap := d.marshalInternal() + return json.Marshal(objectMap) +} + +func (d DataSourcesSpec) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "extensions", d.Extensions) + populate(objectMap, "performanceCounters", d.PerformanceCounters) + populate(objectMap, "syslog", d.Syslog) + populate(objectMap, "windowsEventLogs", d.WindowsEventLogs) + return objectMap +} + +// DestinationsSpec - Specification of destinations that can be used in data flows. +type DestinationsSpec struct { + // Azure Monitor Metrics destination. + AzureMonitorMetrics *DestinationsSpecAzureMonitorMetrics `json:"azureMonitorMetrics,omitempty"` + + // List of Log Analytics destinations. + LogAnalytics []*LogAnalyticsDestination `json:"logAnalytics,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DestinationsSpec. +func (d DestinationsSpec) MarshalJSON() ([]byte, error) { + objectMap := d.marshalInternal() + return json.Marshal(objectMap) +} + +func (d DestinationsSpec) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "azureMonitorMetrics", d.AzureMonitorMetrics) + populate(objectMap, "logAnalytics", d.LogAnalytics) + return objectMap +} + +// DestinationsSpecAzureMonitorMetrics - Azure Monitor Metrics destination. +type DestinationsSpecAzureMonitorMetrics struct { + AzureMonitorMetricsDestination +} + +// DiagnosticSettings - The diagnostic settings. +type DiagnosticSettings struct { + // The resource Id for the event hub authorization rule. + EventHubAuthorizationRuleID *string `json:"eventHubAuthorizationRuleId,omitempty"` + + // The name of the event hub. If none is specified, the default event hub will be selected. + EventHubName *string `json:"eventHubName,omitempty"` + + // 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"` + + // The list of logs settings. + Logs []*LogSettings `json:"logs,omitempty"` + + // The list of metric settings. + Metrics []*MetricSettings `json:"metrics,omitempty"` + + // The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. + ServiceBusRuleID *string `json:"serviceBusRuleId,omitempty"` + + // The resource ID of the storage account to which you would like to send Diagnostic Logs. + StorageAccountID *string `json:"storageAccountId,omitempty"` + + // 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type DiagnosticSettings. +func (d DiagnosticSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "eventHubAuthorizationRuleId", d.EventHubAuthorizationRuleID) + populate(objectMap, "eventHubName", d.EventHubName) + populate(objectMap, "logAnalyticsDestinationType", d.LogAnalyticsDestinationType) + populate(objectMap, "logs", d.Logs) + populate(objectMap, "metrics", d.Metrics) + populate(objectMap, "serviceBusRuleId", d.ServiceBusRuleID) + populate(objectMap, "storageAccountId", d.StorageAccountID) + populate(objectMap, "workspaceId", d.WorkspaceID) + return json.Marshal(objectMap) +} + +// DiagnosticSettingsCategory - The diagnostic settings Category. +type DiagnosticSettingsCategory struct { + // The type of the diagnostic settings category. + CategoryType *CategoryType `json:"categoryType,omitempty"` +} + +// DiagnosticSettingsCategoryGetOptions contains the optional parameters for the DiagnosticSettingsCategory.Get method. +type DiagnosticSettingsCategoryGetOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticSettingsCategoryListOptions contains the optional parameters for the DiagnosticSettingsCategory.List method. +type DiagnosticSettingsCategoryListOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticSettingsCategoryResource - The diagnostic settings category resource. +type DiagnosticSettingsCategoryResource struct { + ProxyOnlyResource + // The properties of a Diagnostic Settings Category. + Properties *DiagnosticSettingsCategory `json:"properties,omitempty"` +} + +// DiagnosticSettingsCategoryResourceCollection - Represents a collection of diagnostic setting category resources. +type DiagnosticSettingsCategoryResourceCollection struct { + // The collection of diagnostic settings category resources. + Value []*DiagnosticSettingsCategoryResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DiagnosticSettingsCategoryResourceCollection. +func (d DiagnosticSettingsCategoryResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DiagnosticSettingsCreateOrUpdateOptions contains the optional parameters for the DiagnosticSettings.CreateOrUpdate method. +type DiagnosticSettingsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticSettingsDeleteOptions contains the optional parameters for the DiagnosticSettings.Delete method. +type DiagnosticSettingsDeleteOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticSettingsGetOptions contains the optional parameters for the DiagnosticSettings.Get method. +type DiagnosticSettingsGetOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticSettingsListOptions contains the optional parameters for the DiagnosticSettings.List method. +type DiagnosticSettingsListOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticSettingsResource - The diagnostic setting resource. +type DiagnosticSettingsResource struct { + ProxyOnlyResource + // Properties of a Diagnostic Settings Resource. + Properties *DiagnosticSettings `json:"properties,omitempty"` +} + +// DiagnosticSettingsResourceCollection - Represents a collection of alert rule resources. +type DiagnosticSettingsResourceCollection struct { + // The collection of diagnostic settings resources;. + Value []*DiagnosticSettingsResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DiagnosticSettingsResourceCollection. +func (d DiagnosticSettingsResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// Dimension - Specifies the criteria for converting log to metric. +type Dimension struct { + // REQUIRED; Name of the dimension + Name *string `json:"name,omitempty"` + + // REQUIRED; Operator for dimension values + Operator *Operator `json:"operator,omitempty"` + + // REQUIRED; List of dimension values + Values []*string `json:"values,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Dimension. +func (d Dimension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", d.Name) + populate(objectMap, "operator", d.Operator) + populate(objectMap, "values", d.Values) + return json.Marshal(objectMap) +} + +// DynamicMetricCriteria - Criterion for dynamic threshold. +type DynamicMetricCriteria struct { + MultiMetricCriteria + // REQUIRED; The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. + AlertSensitivity *DynamicThresholdSensitivity `json:"alertSensitivity,omitempty"` + + // REQUIRED; The minimum number of violations required within the selected lookback time window required to raise an alert. + FailingPeriods *DynamicThresholdFailingPeriods `json:"failingPeriods,omitempty"` + + // REQUIRED; The operator used to compare the metric value against the threshold. + Operator *DynamicThresholdOperator `json:"operator,omitempty"` + + // 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 *time.Time `json:"ignoreDataBefore,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DynamicMetricCriteria. +func (d DynamicMetricCriteria) MarshalJSON() ([]byte, error) { + objectMap := d.MultiMetricCriteria.marshalInternal(CriterionTypeDynamicThresholdCriterion) + populate(objectMap, "alertSensitivity", d.AlertSensitivity) + populate(objectMap, "failingPeriods", d.FailingPeriods) + populate(objectMap, "ignoreDataBefore", (*timeRFC3339)(d.IgnoreDataBefore)) + populate(objectMap, "operator", d.Operator) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DynamicMetricCriteria. +func (d *DynamicMetricCriteria) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "alertSensitivity": + err = unpopulate(val, &d.AlertSensitivity) + delete(rawMsg, key) + case "failingPeriods": + err = unpopulate(val, &d.FailingPeriods) + delete(rawMsg, key) + case "ignoreDataBefore": + var aux timeRFC3339 + err = unpopulate(val, &aux) + d.IgnoreDataBefore = (*time.Time)(&aux) + delete(rawMsg, key) + case "operator": + err = unpopulate(val, &d.Operator) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return d.MultiMetricCriteria.unmarshalInternal(rawMsg) +} + +// DynamicThresholdFailingPeriods - The minimum number of violations required within the selected lookback time window required to raise an alert. +type DynamicThresholdFailingPeriods struct { + // REQUIRED; The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. + MinFailingPeriodsToAlert *float32 `json:"minFailingPeriodsToAlert,omitempty"` + + // REQUIRED; 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 *float32 `json:"numberOfEvaluationPeriods,omitempty"` +} + +// EmailNotification - Email notification of an autoscale event. +type EmailNotification struct { + // 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"` + + // a value indicating whether to send email to subscription administrator. + SendToSubscriptionAdministrator *bool `json:"sendToSubscriptionAdministrator,omitempty"` + + // a value indicating whether to send email to subscription co-administrators. + SendToSubscriptionCoAdministrators *bool `json:"sendToSubscriptionCoAdministrators,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EmailNotification. +func (e EmailNotification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "customEmails", e.CustomEmails) + populate(objectMap, "sendToSubscriptionAdministrator", e.SendToSubscriptionAdministrator) + populate(objectMap, "sendToSubscriptionCoAdministrators", e.SendToSubscriptionCoAdministrators) + return json.Marshal(objectMap) +} + +// EmailReceiver - An email receiver. +type EmailReceiver struct { + // REQUIRED; The email address of this receiver. + EmailAddress *string `json:"emailAddress,omitempty"` + + // REQUIRED; The name of the email receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + + // Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` + + // READ-ONLY; The receiver status of the e-mail. + Status *ReceiverStatus `json:"status,omitempty" azure:"ro"` +} + +// EnableRequest - Describes a receiver that should be resubscribed. +type EnableRequest struct { + // REQUIRED; The name of the receiver to resubscribe. + ReceiverName *string `json:"receiverName,omitempty"` +} + +// Error details. +type Error struct { + // REQUIRED; Error code identifying the specific error. + Code *string `json:"code,omitempty"` + + // Error message in the caller's locale. + Message *string `json:"message,omitempty"` +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorContract - Describes the format of Error response. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorContract struct { + raw string + // The error details. + InnerError *ErrorResponse `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorContract. +// The contents of the error text are not contractual and subject to change. +func (e ErrorContract) Error() string { + return e.raw +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// ErrorResponse - Describes the format of Error response. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // Error code + Code *string `json:"code,omitempty"` + + // Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// ErrorResponseCommon - The resource management error response. +type ErrorResponseCommon struct { + ErrorResponse + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorResponseCommon `json:"details,omitempty" azure:"ro"` +} + +// 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.). +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponseCommonV2 struct { + raw string + // The error object. + InnerError *ErrorDetail `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponseCommonV2. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponseCommonV2) Error() string { + return e.raw +} + +// EventCategoriesListOptions contains the optional parameters for the EventCategories.List method. +type EventCategoriesListOptions struct { + // placeholder for future optional parameters +} + +// EventCategoryCollection - A collection of event categories. Currently possible values are: Administrative, Security, ServiceHealth, Alert, Recommendation, +// Policy. +type EventCategoryCollection struct { + // REQUIRED; the list that includes the Azure event categories. + Value []*LocalizableString `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventCategoryCollection. +func (e EventCategoryCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// EventData - The Azure event log entries are of type EventData +type EventData struct { + // READ-ONLY; The sender authorization information. + Authorization *SenderAuthorization `json:"authorization,omitempty" azure:"ro"` + + // 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" azure:"ro"` + + // READ-ONLY; the event category. + Category *LocalizableString `json:"category,omitempty" azure:"ro"` + + // READ-ONLY; key value pairs to identify ARM permissions. + Claims map[string]*string `json:"claims,omitempty" azure:"ro"` + + // 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" azure:"ro"` + + // READ-ONLY; the description of the event. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; the event data Id. This is a unique identifier for an event. + EventDataID *string `json:"eventDataId,omitempty" azure:"ro"` + + // 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" azure:"ro"` + + // 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 *time.Time `json:"eventTimestamp,omitempty" azure:"ro"` + + // 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" azure:"ro"` + + // 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" azure:"ro"` + + // READ-ONLY; the event level + Level *EventLevel `json:"level,omitempty" azure:"ro"` + + // 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" azure:"ro"` + + // READ-ONLY; the operation name. + OperationName *LocalizableString `json:"operationName,omitempty" azure:"ro"` + + // READ-ONLY; the set of pairs (usually a Dictionary) that includes details about the event. + Properties map[string]*string `json:"properties,omitempty" azure:"ro"` + + // READ-ONLY; the resource group name of the impacted resource. + ResourceGroupName *string `json:"resourceGroupName,omitempty" azure:"ro"` + + // READ-ONLY; the resource uri that uniquely identifies the resource that caused this event. + ResourceID *string `json:"resourceId,omitempty" azure:"ro"` + + // READ-ONLY; the resource provider name of the impacted resource. + ResourceProviderName *LocalizableString `json:"resourceProviderName,omitempty" azure:"ro"` + + // READ-ONLY; the resource type + ResourceType *LocalizableString `json:"resourceType,omitempty" azure:"ro"` + + // 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" azure:"ro"` + + // 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" azure:"ro"` + + // 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 *time.Time `json:"submissionTimestamp,omitempty" azure:"ro"` + + // READ-ONLY; the Azure subscription Id usually a GUID. + SubscriptionID *string `json:"subscriptionId,omitempty" azure:"ro"` + + // READ-ONLY; the Azure tenant Id + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventData. +func (e EventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authorization", e.Authorization) + populate(objectMap, "caller", e.Caller) + populate(objectMap, "category", e.Category) + populate(objectMap, "claims", e.Claims) + populate(objectMap, "correlationId", e.CorrelationID) + populate(objectMap, "description", e.Description) + populate(objectMap, "eventDataId", e.EventDataID) + populate(objectMap, "eventName", e.EventName) + populate(objectMap, "eventTimestamp", (*timeRFC3339)(e.EventTimestamp)) + populate(objectMap, "httpRequest", e.HTTPRequest) + populate(objectMap, "id", e.ID) + populate(objectMap, "level", e.Level) + populate(objectMap, "operationId", e.OperationID) + populate(objectMap, "operationName", e.OperationName) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "resourceGroupName", e.ResourceGroupName) + populate(objectMap, "resourceId", e.ResourceID) + populate(objectMap, "resourceProviderName", e.ResourceProviderName) + populate(objectMap, "resourceType", e.ResourceType) + populate(objectMap, "status", e.Status) + populate(objectMap, "subStatus", e.SubStatus) + populate(objectMap, "submissionTimestamp", (*timeRFC3339)(e.SubmissionTimestamp)) + populate(objectMap, "subscriptionId", e.SubscriptionID) + populate(objectMap, "tenantId", e.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventData. +func (e *EventData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "authorization": + err = unpopulate(val, &e.Authorization) + delete(rawMsg, key) + case "caller": + err = unpopulate(val, &e.Caller) + delete(rawMsg, key) + case "category": + err = unpopulate(val, &e.Category) + delete(rawMsg, key) + case "claims": + err = unpopulate(val, &e.Claims) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, &e.CorrelationID) + delete(rawMsg, key) + case "description": + err = unpopulate(val, &e.Description) + delete(rawMsg, key) + case "eventDataId": + err = unpopulate(val, &e.EventDataID) + delete(rawMsg, key) + case "eventName": + err = unpopulate(val, &e.EventName) + delete(rawMsg, key) + case "eventTimestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + e.EventTimestamp = (*time.Time)(&aux) + delete(rawMsg, key) + case "httpRequest": + err = unpopulate(val, &e.HTTPRequest) + delete(rawMsg, key) + case "id": + err = unpopulate(val, &e.ID) + delete(rawMsg, key) + case "level": + err = unpopulate(val, &e.Level) + delete(rawMsg, key) + case "operationId": + err = unpopulate(val, &e.OperationID) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, &e.OperationName) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, &e.Properties) + delete(rawMsg, key) + case "resourceGroupName": + err = unpopulate(val, &e.ResourceGroupName) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, &e.ResourceID) + delete(rawMsg, key) + case "resourceProviderName": + err = unpopulate(val, &e.ResourceProviderName) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, &e.ResourceType) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &e.Status) + delete(rawMsg, key) + case "subStatus": + err = unpopulate(val, &e.SubStatus) + delete(rawMsg, key) + case "submissionTimestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + e.SubmissionTimestamp = (*time.Time)(&aux) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, &e.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, &e.TenantID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// EventDataCollection - Represents collection of events. +type EventDataCollection struct { + // REQUIRED; this list that includes the Azure audit logs. + Value []*EventData `json:"value,omitempty"` + + // Provides the link to retrieve the next set of events. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventDataCollection. +func (e EventDataCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// 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 { + // REQUIRED; The name of the VM extension. + ExtensionName *string `json:"extensionName,omitempty"` + + // The extension settings. The format is specific for particular extension. + ExtensionSettings map[string]interface{} `json:"extensionSettings,omitempty"` + + // The list of data sources this extension needs data from. + InputDataSources []*string `json:"inputDataSources,omitempty"` + + // 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"` + + // 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionDataSource. +func (e ExtensionDataSource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extensionName", e.ExtensionName) + populate(objectMap, "extensionSettings", e.ExtensionSettings) + populate(objectMap, "inputDataSources", e.InputDataSources) + populate(objectMap, "name", e.Name) + populate(objectMap, "streams", e.Streams) + return json.Marshal(objectMap) +} + +// HTTPRequestInfo - The Http request info. +type HTTPRequestInfo struct { + // the client Ip Address + ClientIPAddress *string `json:"clientIpAddress,omitempty"` + + // the client request id. + ClientRequestID *string `json:"clientRequestId,omitempty"` + + // the Http request method. + Method *string `json:"method,omitempty"` + + // the Uri. + URI *string `json:"uri,omitempty"` +} + +// Incident - An alert incident indicates the activation status of an alert rule. +type Incident struct { + // READ-ONLY; The time at which the incident was activated in ISO8601 format. + ActivatedTime *time.Time `json:"activatedTime,omitempty" azure:"ro"` + + // READ-ONLY; A boolean to indicate whether the incident is active or resolved. + IsActive *bool `json:"isActive,omitempty" azure:"ro"` + + // READ-ONLY; Incident name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The time at which the incident was resolved in ISO8601 format. If null, it means the incident is still active. + ResolvedTime *time.Time `json:"resolvedTime,omitempty" azure:"ro"` + + // READ-ONLY; Rule name that is associated with the incident. + RuleName *string `json:"ruleName,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Incident. +func (i Incident) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "activatedTime", (*timeRFC3339)(i.ActivatedTime)) + populate(objectMap, "isActive", i.IsActive) + populate(objectMap, "name", i.Name) + populate(objectMap, "resolvedTime", (*timeRFC3339)(i.ResolvedTime)) + populate(objectMap, "ruleName", i.RuleName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Incident. +func (i *Incident) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "activatedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + i.ActivatedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "isActive": + err = unpopulate(val, &i.IsActive) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &i.Name) + delete(rawMsg, key) + case "resolvedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + i.ResolvedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "ruleName": + err = unpopulate(val, &i.RuleName) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// IncidentListResult - The List incidents operation response. +type IncidentListResult struct { + // the incident collection. + Value []*Incident `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IncidentListResult. +func (i IncidentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// ItsmReceiver - An Itsm receiver. +type ItsmReceiver struct { + // REQUIRED; Unique identification of ITSM connection among multiple defined in above workspace. + ConnectionID *string `json:"connectionId,omitempty"` + + // REQUIRED; The name of the Itsm receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + + // REQUIRED; Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope' + Region *string `json:"region,omitempty"` + + // REQUIRED; JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. + TicketConfiguration *string `json:"ticketConfiguration,omitempty"` + + // REQUIRED; OMS LA instance identifier. + WorkspaceID *string `json:"workspaceId,omitempty"` +} + +// LocalizableString - The localizable string class. +type LocalizableString struct { + // REQUIRED; the invariant value. + Value *string `json:"value,omitempty"` + + // the locale specific value. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// LocationThresholdRuleCondition - A rule condition based on a certain number of locations failing. +type LocationThresholdRuleCondition struct { + RuleCondition + // REQUIRED; the number of locations that must fail to activate the alert. + FailedLocationCount *int32 `json:"failedLocationCount,omitempty"` + + // 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type LocationThresholdRuleCondition. +func (l LocationThresholdRuleCondition) MarshalJSON() ([]byte, error) { + objectMap := l.RuleCondition.marshalInternal("Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition") + populate(objectMap, "failedLocationCount", l.FailedLocationCount) + populate(objectMap, "windowSize", l.WindowSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LocationThresholdRuleCondition. +func (l *LocationThresholdRuleCondition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "failedLocationCount": + err = unpopulate(val, &l.FailedLocationCount) + delete(rawMsg, key) + case "windowSize": + err = unpopulate(val, &l.WindowSize) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return l.RuleCondition.unmarshalInternal(rawMsg) +} + +// LogAnalyticsDestination - Log Analytics destination. +type LogAnalyticsDestination struct { + // 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"` + + // The resource ID of the Log Analytics workspace. + WorkspaceResourceID *string `json:"workspaceResourceId,omitempty"` + + // READ-ONLY; The Customer ID of the Log Analytics workspace. + WorkspaceID *string `json:"workspaceId,omitempty" azure:"ro"` +} + +// LogMetricTrigger - A log metrics trigger descriptor. +type LogMetricTrigger struct { + // Evaluation of metric on a particular column + MetricColumn *string `json:"metricColumn,omitempty"` + + // Metric Trigger Type - 'Consecutive' or 'Total' + MetricTriggerType *MetricTriggerType `json:"metricTriggerType,omitempty"` + + // The threshold of the metric trigger. + Threshold *float64 `json:"threshold,omitempty"` + + // Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. + ThresholdOperator *ConditionalOperator `json:"thresholdOperator,omitempty"` +} + +// LogProfileCollection - Represents a collection of log profiles. +type LogProfileCollection struct { + // REQUIRED; the values of the log profiles. + Value []*LogProfileResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LogProfileCollection. +func (l LogProfileCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// LogProfileProperties - The log profile properties. +type LogProfileProperties struct { + // REQUIRED; 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"` + + // REQUIRED; 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"` + + // REQUIRED; the retention policy for the events in the log. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` + + // 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"` + + // the resource id of the storage account to which you would like to send the Activity Log. + StorageAccountID *string `json:"storageAccountId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LogProfileProperties. +func (l LogProfileProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "categories", l.Categories) + populate(objectMap, "locations", l.Locations) + populate(objectMap, "retentionPolicy", l.RetentionPolicy) + populate(objectMap, "serviceBusRuleId", l.ServiceBusRuleID) + populate(objectMap, "storageAccountId", l.StorageAccountID) + return json.Marshal(objectMap) +} + +// LogProfileResource - The log profile resource. +type LogProfileResource struct { + Resource + // REQUIRED; The log profile properties of the resource. + Properties *LogProfileProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LogProfileResource. +func (l LogProfileResource) MarshalJSON() ([]byte, error) { + objectMap := l.Resource.marshalInternal() + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + +// LogProfileResourcePatch - The log profile resource for patch operations. +type LogProfileResourcePatch struct { + // The log profile properties for an update operation. + Properties *LogProfileProperties `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LogProfileResourcePatch. +func (l LogProfileResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "tags", l.Tags) + return json.Marshal(objectMap) +} + +// LogProfilesCreateOrUpdateOptions contains the optional parameters for the LogProfiles.CreateOrUpdate method. +type LogProfilesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// LogProfilesDeleteOptions contains the optional parameters for the LogProfiles.Delete method. +type LogProfilesDeleteOptions struct { + // placeholder for future optional parameters +} + +// LogProfilesGetOptions contains the optional parameters for the LogProfiles.Get method. +type LogProfilesGetOptions struct { + // placeholder for future optional parameters +} + +// LogProfilesListOptions contains the optional parameters for the LogProfiles.List method. +type LogProfilesListOptions struct { + // placeholder for future optional parameters +} + +// LogProfilesUpdateOptions contains the optional parameters for the LogProfiles.Update method. +type LogProfilesUpdateOptions struct { + // placeholder for future optional parameters +} + +// LogSearchRule - Log Search Rule Definition +type LogSearchRule struct { + // REQUIRED; Action needs to be taken on rule execution. + Action ActionClassification `json:"action,omitempty"` + + // REQUIRED; Data Source against which rule will Query Data + Source *Source `json:"source,omitempty"` + + // The flag that indicates whether the alert should be automatically resolved or not. The default is false. + AutoMitigate *bool `json:"autoMitigate,omitempty"` + + // The description of the Log Search rule. + Description *string `json:"description,omitempty"` + + // The display name of the alert rule + DisplayName *string `json:"displayName,omitempty"` + + // The flag which indicates whether the Log Search rule is enabled. Value should be true or false + Enabled *Enabled `json:"enabled,omitempty"` + + // Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction + Schedule *Schedule `json:"schedule,omitempty"` + + // READ-ONLY; The api-version used when creating this alert rule + CreatedWithAPIVersion *string `json:"createdWithApiVersion,omitempty" azure:"ro"` + + // READ-ONLY; True if alert rule is legacy Log Analytic rule + IsLegacyLogAnalyticsRule *bool `json:"isLegacyLogAnalyticsRule,omitempty" azure:"ro"` + + // READ-ONLY; Last time the rule was updated in IS08601 format. + LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state of the scheduled query rule + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type LogSearchRule. +func (l LogSearchRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "action", l.Action) + populate(objectMap, "autoMitigate", l.AutoMitigate) + populate(objectMap, "createdWithApiVersion", l.CreatedWithAPIVersion) + populate(objectMap, "description", l.Description) + populate(objectMap, "displayName", l.DisplayName) + populate(objectMap, "enabled", l.Enabled) + populate(objectMap, "isLegacyLogAnalyticsRule", l.IsLegacyLogAnalyticsRule) + populate(objectMap, "lastUpdatedTime", (*timeRFC3339)(l.LastUpdatedTime)) + populate(objectMap, "provisioningState", l.ProvisioningState) + populate(objectMap, "schedule", l.Schedule) + populate(objectMap, "source", l.Source) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogSearchRule. +func (l *LogSearchRule) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + l.Action, err = unmarshalActionClassification(val) + delete(rawMsg, key) + case "autoMitigate": + err = unpopulate(val, &l.AutoMitigate) + delete(rawMsg, key) + case "createdWithApiVersion": + err = unpopulate(val, &l.CreatedWithAPIVersion) + delete(rawMsg, key) + case "description": + err = unpopulate(val, &l.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, &l.DisplayName) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, &l.Enabled) + delete(rawMsg, key) + case "isLegacyLogAnalyticsRule": + err = unpopulate(val, &l.IsLegacyLogAnalyticsRule) + delete(rawMsg, key) + case "lastUpdatedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + l.LastUpdatedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &l.ProvisioningState) + delete(rawMsg, key) + case "schedule": + err = unpopulate(val, &l.Schedule) + delete(rawMsg, key) + case "source": + err = unpopulate(val, &l.Source) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// LogSearchRulePatch - Log Search Rule Definition for Patching +type LogSearchRulePatch struct { + // The flag which indicates whether the Log Search rule is enabled. Value should be true or false + Enabled *Enabled `json:"enabled,omitempty"` +} + +// LogSearchRuleResource - The Log Search Rule resource. +type LogSearchRuleResource struct { + TrackedEntityResource + // REQUIRED; The rule properties of the resource. + Properties *LogSearchRule `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LogSearchRuleResource. +func (l LogSearchRuleResource) MarshalJSON() ([]byte, error) { + objectMap := l.TrackedEntityResource.marshalInternal() + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + +// LogSearchRuleResourceCollection - Represents a collection of Log Search rule resources. +type LogSearchRuleResourceCollection struct { + // The values for the Log Search Rule resources. + Value []*LogSearchRuleResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LogSearchRuleResourceCollection. +func (l LogSearchRuleResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// LogSearchRuleResourcePatch - The log search rule resource for patch operations. +type LogSearchRuleResourcePatch struct { + // The log search rule properties of the resource. + Properties *LogSearchRulePatch `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LogSearchRuleResourcePatch. +func (l LogSearchRuleResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "tags", l.Tags) + return json.Marshal(objectMap) +} + +// LogSettings - Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. +type LogSettings struct { + // REQUIRED; a value indicating whether this log is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // 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"` + + // the retention policy for this log. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// LogToMetricAction - Specify action need to be taken when rule type is converting log to metric +type LogToMetricAction struct { + Action + // REQUIRED; Criteria of Metric + Criteria []*Criteria `json:"criteria,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LogToMetricAction. +func (l LogToMetricAction) MarshalJSON() ([]byte, error) { + objectMap := l.Action.marshalInternal("Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction") + populate(objectMap, "criteria", l.Criteria) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogToMetricAction. +func (l *LogToMetricAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "criteria": + err = unpopulate(val, &l.Criteria) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return l.Action.unmarshalInternal(rawMsg) +} + +// LogicAppReceiver - A logic app receiver. +type LogicAppReceiver struct { + // REQUIRED; The callback url where http request sent to. + CallbackURL *string `json:"callbackUrl,omitempty"` + + // REQUIRED; The name of the logic app receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + + // REQUIRED; The azure resource id of the logic app receiver. + ResourceID *string `json:"resourceId,omitempty"` + + // Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// LogsIngestionEndpointSpec - Definition of the endpoint used for ingesting logs. +type LogsIngestionEndpointSpec struct { + // READ-ONLY; The endpoint. This property is READ-ONLY. + Endpoint *string `json:"endpoint,omitempty" azure:"ro"` +} + +// ManagementEventAggregationCondition - How the data that is collected should be combined over time. +type ManagementEventAggregationCondition struct { + // the condition operator. + Operator *ConditionOperator `json:"operator,omitempty"` + + // The threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + + // 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 { + RuleCondition + // 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementEventRuleCondition. +func (m ManagementEventRuleCondition) MarshalJSON() ([]byte, error) { + objectMap := m.RuleCondition.marshalInternal("Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition") + populate(objectMap, "aggregation", m.Aggregation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagementEventRuleCondition. +func (m *ManagementEventRuleCondition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "aggregation": + err = unpopulate(val, &m.Aggregation) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return m.RuleCondition.unmarshalInternal(rawMsg) +} + +// MetadataValue - Represents a metric metadata value. +type MetadataValue struct { + // the name of the metadata. + Name *LocalizableString `json:"name,omitempty"` + + // the value of the metadata. + Value *string `json:"value,omitempty"` +} + +// Metric - The result data of a query. +type Metric struct { + // REQUIRED; the metric Id. + ID *string `json:"id,omitempty"` + + // REQUIRED; the name and the display name of the metric, i.e. it is localizable string. + Name *LocalizableString `json:"name,omitempty"` + + // REQUIRED; the time series returned when a data query is performed. + Timeseries []*TimeSeriesElement `json:"timeseries,omitempty"` + + // REQUIRED; the resource type of the metric resource. + Type *string `json:"type,omitempty"` + + // REQUIRED; The unit of the metric. + Unit *MetricUnit `json:"unit,omitempty"` + + // Detailed description of this metric. + DisplayDescription *string `json:"displayDescription,omitempty"` + + // 'Success' or the error details on query failures for this metric. + ErrorCode *string `json:"errorCode,omitempty"` + + // Error message encountered querying this specific metric. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Metric. +func (m Metric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayDescription", m.DisplayDescription) + populate(objectMap, "errorCode", m.ErrorCode) + populate(objectMap, "errorMessage", m.ErrorMessage) + populate(objectMap, "id", m.ID) + populate(objectMap, "name", m.Name) + populate(objectMap, "timeseries", m.Timeseries) + populate(objectMap, "type", m.Type) + populate(objectMap, "unit", m.Unit) + return json.Marshal(objectMap) +} + +// MetricAlertAction - An alert action. +type MetricAlertAction struct { + // the id of the action group to use. + ActionGroupID *string `json:"actionGroupId,omitempty"` + + // 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,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricAlertAction. +func (m MetricAlertAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionGroupId", m.ActionGroupID) + populate(objectMap, "webHookProperties", m.WebHookProperties) + return json.Marshal(objectMap) +} + +// MetricAlertCriteriaClassification provides polymorphic access to related types. +// Call the interface's GetMetricAlertCriteria() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *MetricAlertCriteria, *MetricAlertMultipleResourceMultipleMetricCriteria, *MetricAlertSingleResourceMultipleMetricCriteria, +// - *WebtestLocationAvailabilityCriteria +type MetricAlertCriteriaClassification interface { + // GetMetricAlertCriteria returns the MetricAlertCriteria content of the underlying type. + GetMetricAlertCriteria() *MetricAlertCriteria +} + +// MetricAlertCriteria - The rule criteria that defines the conditions of the alert rule. +type MetricAlertCriteria struct { + // REQUIRED; specifies the type of the alert criteria. + OdataType *Odatatype `json:"odata.type,omitempty"` + + // OPTIONAL; Contains additional key/value pairs not defined in the schema. + AdditionalProperties map[string]map[string]interface{} +} + +// GetMetricAlertCriteria implements the MetricAlertCriteriaClassification interface for type MetricAlertCriteria. +func (m *MetricAlertCriteria) GetMetricAlertCriteria() *MetricAlertCriteria { return m } + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricAlertCriteria. +func (m *MetricAlertCriteria) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return m.unmarshalInternal(rawMsg) +} + +func (m MetricAlertCriteria) marshalInternal(discValue Odatatype) map[string]interface{} { + objectMap := make(map[string]interface{}) + m.OdataType = &discValue + objectMap["odata.type"] = m.OdataType + if m.AdditionalProperties != nil { + for key, val := range m.AdditionalProperties { + objectMap[key] = val + } + } + return objectMap +} + +func (m *MetricAlertCriteria) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "odata.type": + err = unpopulate(val, &m.OdataType) + delete(rawMsg, key) + default: + if m.AdditionalProperties == nil { + m.AdditionalProperties = map[string]map[string]interface{}{} + } + if val != nil { + var aux map[string]interface{} + err = json.Unmarshal(val, &aux) + m.AdditionalProperties[key] = aux + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MetricAlertMultipleResourceMultipleMetricCriteria - Specifies the metric alert criteria for multiple resource that has multiple metric criteria. +type MetricAlertMultipleResourceMultipleMetricCriteria struct { + MetricAlertCriteria + // the list of multiple metric criteria for this 'all of' operation. + AllOf []MultiMetricCriteriaClassification `json:"allOf,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricAlertMultipleResourceMultipleMetricCriteria. +func (m MetricAlertMultipleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) { + objectMap := m.MetricAlertCriteria.marshalInternal(OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria) + populate(objectMap, "allOf", m.AllOf) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricAlertMultipleResourceMultipleMetricCriteria. +func (m *MetricAlertMultipleResourceMultipleMetricCriteria) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "allOf": + m.AllOf, err = unmarshalMultiMetricCriteriaClassificationArray(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return m.MetricAlertCriteria.unmarshalInternal(rawMsg) +} + +// MetricAlertProperties - An alert rule. +type MetricAlertProperties struct { + // REQUIRED; defines the specific alert criteria information. + Criteria MetricAlertCriteriaClassification `json:"criteria,omitempty"` + + // REQUIRED; the flag that indicates whether the metric alert is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // REQUIRED; how often the metric alert is evaluated represented in ISO 8601 duration format. + EvaluationFrequency *string `json:"evaluationFrequency,omitempty"` + + // REQUIRED; the list of resource id's that this metric alert is scoped to. + Scopes []*string `json:"scopes,omitempty"` + + // REQUIRED; Alert severity {0, 1, 2, 3, 4} + Severity *int32 `json:"severity,omitempty"` + + // REQUIRED; 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"` + + // 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"` + + // the flag that indicates whether the alert should be auto resolved or not. The default is true. + AutoMitigate *bool `json:"autoMitigate,omitempty"` + + // the description of the metric alert that will be included in the alert email. + Description *string `json:"description,omitempty"` + + // 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"` + + // 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"` + + // READ-ONLY; the value indicating whether this alert rule is migrated. + IsMigrated *bool `json:"isMigrated,omitempty" azure:"ro"` + + // READ-ONLY; Last time the rule was updated in ISO8601 format. + LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricAlertProperties. +func (m MetricAlertProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actions", m.Actions) + populate(objectMap, "autoMitigate", m.AutoMitigate) + populate(objectMap, "criteria", m.Criteria) + populate(objectMap, "description", m.Description) + populate(objectMap, "enabled", m.Enabled) + populate(objectMap, "evaluationFrequency", m.EvaluationFrequency) + populate(objectMap, "isMigrated", m.IsMigrated) + populate(objectMap, "lastUpdatedTime", (*timeRFC3339)(m.LastUpdatedTime)) + populate(objectMap, "scopes", m.Scopes) + populate(objectMap, "severity", m.Severity) + populate(objectMap, "targetResourceRegion", m.TargetResourceRegion) + populate(objectMap, "targetResourceType", m.TargetResourceType) + populate(objectMap, "windowSize", m.WindowSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricAlertProperties. +func (m *MetricAlertProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "actions": + err = unpopulate(val, &m.Actions) + delete(rawMsg, key) + case "autoMitigate": + err = unpopulate(val, &m.AutoMitigate) + delete(rawMsg, key) + case "criteria": + m.Criteria, err = unmarshalMetricAlertCriteriaClassification(val) + delete(rawMsg, key) + case "description": + err = unpopulate(val, &m.Description) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, &m.Enabled) + delete(rawMsg, key) + case "evaluationFrequency": + err = unpopulate(val, &m.EvaluationFrequency) + delete(rawMsg, key) + case "isMigrated": + err = unpopulate(val, &m.IsMigrated) + delete(rawMsg, key) + case "lastUpdatedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + m.LastUpdatedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "scopes": + err = unpopulate(val, &m.Scopes) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, &m.Severity) + delete(rawMsg, key) + case "targetResourceRegion": + err = unpopulate(val, &m.TargetResourceRegion) + delete(rawMsg, key) + case "targetResourceType": + err = unpopulate(val, &m.TargetResourceType) + delete(rawMsg, key) + case "windowSize": + err = unpopulate(val, &m.WindowSize) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MetricAlertPropertiesPatch - An alert rule properties for patch. +type MetricAlertPropertiesPatch struct { + // 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"` + + // the flag that indicates whether the alert should be auto resolved or not. The default is true. + AutoMitigate *bool `json:"autoMitigate,omitempty"` + + // defines the specific alert criteria information. + Criteria MetricAlertCriteriaClassification `json:"criteria,omitempty"` + + // the description of the metric alert that will be included in the alert email. + Description *string `json:"description,omitempty"` + + // the flag that indicates whether the metric alert is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // how often the metric alert is evaluated represented in ISO 8601 duration format. + EvaluationFrequency *string `json:"evaluationFrequency,omitempty"` + + // the list of resource id's that this metric alert is scoped to. + Scopes []*string `json:"scopes,omitempty"` + + // Alert severity {0, 1, 2, 3, 4} + Severity *int32 `json:"severity,omitempty"` + + // the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + TargetResourceRegion *string `json:"targetResourceRegion,omitempty"` + + // the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + TargetResourceType *string `json:"targetResourceType,omitempty"` + + // 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"` + + // READ-ONLY; the value indicating whether this alert rule is migrated. + IsMigrated *bool `json:"isMigrated,omitempty" azure:"ro"` + + // READ-ONLY; Last time the rule was updated in ISO8601 format. + LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricAlertPropertiesPatch. +func (m MetricAlertPropertiesPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actions", m.Actions) + populate(objectMap, "autoMitigate", m.AutoMitigate) + populate(objectMap, "criteria", m.Criteria) + populate(objectMap, "description", m.Description) + populate(objectMap, "enabled", m.Enabled) + populate(objectMap, "evaluationFrequency", m.EvaluationFrequency) + populate(objectMap, "isMigrated", m.IsMigrated) + populate(objectMap, "lastUpdatedTime", (*timeRFC3339)(m.LastUpdatedTime)) + populate(objectMap, "scopes", m.Scopes) + populate(objectMap, "severity", m.Severity) + populate(objectMap, "targetResourceRegion", m.TargetResourceRegion) + populate(objectMap, "targetResourceType", m.TargetResourceType) + populate(objectMap, "windowSize", m.WindowSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricAlertPropertiesPatch. +func (m *MetricAlertPropertiesPatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "actions": + err = unpopulate(val, &m.Actions) + delete(rawMsg, key) + case "autoMitigate": + err = unpopulate(val, &m.AutoMitigate) + delete(rawMsg, key) + case "criteria": + m.Criteria, err = unmarshalMetricAlertCriteriaClassification(val) + delete(rawMsg, key) + case "description": + err = unpopulate(val, &m.Description) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, &m.Enabled) + delete(rawMsg, key) + case "evaluationFrequency": + err = unpopulate(val, &m.EvaluationFrequency) + delete(rawMsg, key) + case "isMigrated": + err = unpopulate(val, &m.IsMigrated) + delete(rawMsg, key) + case "lastUpdatedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + m.LastUpdatedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "scopes": + err = unpopulate(val, &m.Scopes) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, &m.Severity) + delete(rawMsg, key) + case "targetResourceRegion": + err = unpopulate(val, &m.TargetResourceRegion) + delete(rawMsg, key) + case "targetResourceType": + err = unpopulate(val, &m.TargetResourceType) + delete(rawMsg, key) + case "windowSize": + err = unpopulate(val, &m.WindowSize) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MetricAlertResource - The metric alert resource. +type MetricAlertResource struct { + Resource + // REQUIRED; The alert rule properties of the resource. + Properties *MetricAlertProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricAlertResource. +func (m MetricAlertResource) MarshalJSON() ([]byte, error) { + objectMap := m.Resource.marshalInternal() + populate(objectMap, "properties", m.Properties) + return json.Marshal(objectMap) +} + +// MetricAlertResourceCollection - Represents a collection of alert rule resources. +type MetricAlertResourceCollection struct { + // the values for the alert rule resources. + Value []*MetricAlertResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricAlertResourceCollection. +func (m MetricAlertResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// MetricAlertResourcePatch - The metric alert resource for patch operations. +type MetricAlertResourcePatch struct { + // The alert rule properties of the resource. + Properties *MetricAlertPropertiesPatch `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricAlertResourcePatch. +func (m MetricAlertResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "tags", m.Tags) + return json.Marshal(objectMap) +} + +// MetricAlertSingleResourceMultipleMetricCriteria - Specifies the metric alert criteria for a single resource that has multiple metric criteria. +type MetricAlertSingleResourceMultipleMetricCriteria struct { + MetricAlertCriteria + // The list of metric criteria for this 'all of' operation. + AllOf []*MetricCriteria `json:"allOf,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricAlertSingleResourceMultipleMetricCriteria. +func (m MetricAlertSingleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) { + objectMap := m.MetricAlertCriteria.marshalInternal(OdatatypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria) + populate(objectMap, "allOf", m.AllOf) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricAlertSingleResourceMultipleMetricCriteria. +func (m *MetricAlertSingleResourceMultipleMetricCriteria) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "allOf": + err = unpopulate(val, &m.AllOf) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return m.MetricAlertCriteria.unmarshalInternal(rawMsg) +} + +// MetricAlertStatus - An alert status. +type MetricAlertStatus struct { + // The alert rule arm id. + ID *string `json:"id,omitempty"` + + // The status name. + Name *string `json:"name,omitempty"` + + // The alert status properties of the metric alert status. + Properties *MetricAlertStatusProperties `json:"properties,omitempty"` + + // The extended resource type name. + Type *string `json:"type,omitempty"` +} + +// MetricAlertStatusCollection - Represents a collection of alert rule resources. +type MetricAlertStatusCollection struct { + // the values for the alert rule resources. + Value []*MetricAlertStatus `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricAlertStatusCollection. +func (m MetricAlertStatusCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// MetricAlertStatusProperties - An alert status properties. +type MetricAlertStatusProperties struct { + // An object describing the type of the dimensions. + Dimensions map[string]*string `json:"dimensions,omitempty"` + + // status value + Status *string `json:"status,omitempty"` + + // UTC time when the status was checked. + Timestamp *time.Time `json:"timestamp,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricAlertStatusProperties. +func (m MetricAlertStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "status", m.Status) + populate(objectMap, "timestamp", (*timeRFC3339)(m.Timestamp)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricAlertStatusProperties. +func (m *MetricAlertStatusProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "dimensions": + err = unpopulate(val, &m.Dimensions) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &m.Status) + delete(rawMsg, key) + case "timestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + m.Timestamp = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MetricAlertsCreateOrUpdateOptions contains the optional parameters for the MetricAlerts.CreateOrUpdate method. +type MetricAlertsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// MetricAlertsDeleteOptions contains the optional parameters for the MetricAlerts.Delete method. +type MetricAlertsDeleteOptions struct { + // placeholder for future optional parameters +} + +// MetricAlertsGetOptions contains the optional parameters for the MetricAlerts.Get method. +type MetricAlertsGetOptions struct { + // placeholder for future optional parameters +} + +// MetricAlertsListByResourceGroupOptions contains the optional parameters for the MetricAlerts.ListByResourceGroup method. +type MetricAlertsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// MetricAlertsListBySubscriptionOptions contains the optional parameters for the MetricAlerts.ListBySubscription method. +type MetricAlertsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// MetricAlertsStatusListByNameOptions contains the optional parameters for the MetricAlertsStatus.ListByName method. +type MetricAlertsStatusListByNameOptions struct { + // placeholder for future optional parameters +} + +// MetricAlertsStatusListOptions contains the optional parameters for the MetricAlertsStatus.List method. +type MetricAlertsStatusListOptions struct { + // placeholder for future optional parameters +} + +// MetricAlertsUpdateOptions contains the optional parameters for the MetricAlerts.Update method. +type MetricAlertsUpdateOptions struct { + // placeholder for future optional parameters +} + +// MetricAvailability - Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. +type MetricAvailability struct { + // the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. + Retention *string `json:"retention,omitempty"` + + // the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. + TimeGrain *string `json:"timeGrain,omitempty"` +} + +// MetricBaselinesProperties - The response to a metric baselines query. +type MetricBaselinesProperties struct { + // REQUIRED; The baseline for each time series that was queried. + Baselines []*TimeSeriesBaseline `json:"baselines,omitempty"` + + // REQUIRED; 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"` + + // REQUIRED; 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"` + + // The namespace of the metrics been queried. + Namespace *string `json:"namespace,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricBaselinesProperties. +func (m MetricBaselinesProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "baselines", m.Baselines) + populate(objectMap, "interval", m.Interval) + populate(objectMap, "namespace", m.Namespace) + populate(objectMap, "timespan", m.Timespan) + return json.Marshal(objectMap) +} + +// MetricBaselinesResponse - A list of metric baselines. +type MetricBaselinesResponse struct { + // The list of metric baselines. + Value []*SingleMetricBaseline `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricBaselinesResponse. +func (m MetricBaselinesResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// MetricCriteria - Criterion to filter metrics. +type MetricCriteria struct { + MultiMetricCriteria + // REQUIRED; the criteria operator. + Operator *Operator `json:"operator,omitempty"` + + // REQUIRED; the criteria threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricCriteria. +func (m MetricCriteria) MarshalJSON() ([]byte, error) { + objectMap := m.MultiMetricCriteria.marshalInternal(CriterionTypeStaticThresholdCriterion) + populate(objectMap, "operator", m.Operator) + populate(objectMap, "threshold", m.Threshold) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricCriteria. +func (m *MetricCriteria) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "operator": + err = unpopulate(val, &m.Operator) + delete(rawMsg, key) + case "threshold": + err = unpopulate(val, &m.Threshold) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return m.MultiMetricCriteria.unmarshalInternal(rawMsg) +} + +// MetricDefinition - Metric definition class specifies the metadata for a metric. +type MetricDefinition struct { + // Custom category name for this metric. + Category *string `json:"category,omitempty"` + + // the name and the display name of the dimension, i.e. it is a localizable string. + Dimensions []*LocalizableString `json:"dimensions,omitempty"` + + // Detailed description of this metric. + DisplayDescription *string `json:"displayDescription,omitempty"` + + // the resource identifier of the metric definition. + ID *string `json:"id,omitempty"` + + // Flag to indicate whether the dimension is required. + IsDimensionRequired *bool `json:"isDimensionRequired,omitempty"` + + // the collection of what aggregation intervals are available to be queried. + MetricAvailabilities []*MetricAvailability `json:"metricAvailabilities,omitempty"` + + // The class of the metric. + MetricClass *MetricClass `json:"metricClass,omitempty"` + + // the name and the display name of the metric, i.e. it is a localizable string. + Name *LocalizableString `json:"name,omitempty"` + + // the namespace the metric belongs to. + Namespace *string `json:"namespace,omitempty"` + + // the primary aggregation type value defining how to use the values for display. + PrimaryAggregationType *AggregationType `json:"primaryAggregationType,omitempty"` + + // the resource identifier of the resource that emitted the metric. + ResourceID *string `json:"resourceId,omitempty"` + + // the collection of what aggregation types are supported. + SupportedAggregationTypes []*AggregationType `json:"supportedAggregationTypes,omitempty"` + + // The unit of the metric. + Unit *MetricUnit `json:"unit,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricDefinition. +func (m MetricDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "category", m.Category) + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "displayDescription", m.DisplayDescription) + populate(objectMap, "id", m.ID) + populate(objectMap, "isDimensionRequired", m.IsDimensionRequired) + populate(objectMap, "metricAvailabilities", m.MetricAvailabilities) + populate(objectMap, "metricClass", m.MetricClass) + populate(objectMap, "name", m.Name) + populate(objectMap, "namespace", m.Namespace) + populate(objectMap, "primaryAggregationType", m.PrimaryAggregationType) + populate(objectMap, "resourceId", m.ResourceID) + populate(objectMap, "supportedAggregationTypes", m.SupportedAggregationTypes) + populate(objectMap, "unit", m.Unit) + return json.Marshal(objectMap) +} + +// MetricDefinitionCollection - Represents collection of metric definitions. +type MetricDefinitionCollection struct { + // REQUIRED; the values for the metric definitions. + Value []*MetricDefinition `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricDefinitionCollection. +func (m MetricDefinitionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// MetricDefinitionsListOptions contains the optional parameters for the MetricDefinitions.List method. +type MetricDefinitionsListOptions struct { + // Metric namespace to query metric definitions for. + Metricnamespace *string +} + +// MetricDimension - Specifies a metric dimension. +type MetricDimension struct { + // REQUIRED; Name of the dimension. + Name *string `json:"name,omitempty"` + + // REQUIRED; the dimension operator. Only 'Include' and 'Exclude' are supported + Operator *string `json:"operator,omitempty"` + + // REQUIRED; list of dimension values. + Values []*string `json:"values,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricDimension. +func (m MetricDimension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", m.Name) + populate(objectMap, "operator", m.Operator) + populate(objectMap, "values", m.Values) + return json.Marshal(objectMap) +} + +// MetricNamespace - Metric namespace class specifies the metadata for a metric namespace. +type MetricNamespace struct { + // Kind of namespace + Classification *NamespaceClassification `json:"classification,omitempty"` + + // The ID of the metric namespace. + ID *string `json:"id,omitempty"` + + // The escaped name of the namespace. + Name *string `json:"name,omitempty"` + + // Properties which include the fully qualified namespace name. + Properties *MetricNamespaceName `json:"properties,omitempty"` + + // The type of the namespace. + Type *string `json:"type,omitempty"` +} + +// MetricNamespaceCollection - Represents collection of metric namespaces. +type MetricNamespaceCollection struct { + // REQUIRED; The values for the metric namespaces. + Value []*MetricNamespace `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricNamespaceCollection. +func (m MetricNamespaceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// MetricNamespaceName - The fully qualified metric namespace name. +type MetricNamespaceName struct { + // The metric namespace name. + MetricNamespaceName *string `json:"metricNamespaceName,omitempty"` +} + +// MetricNamespacesListOptions contains the optional parameters for the MetricNamespaces.List method. +type MetricNamespacesListOptions struct { + // The ISO 8601 conform Date start time from which to query for metric namespaces. + StartTime *string +} + +// MetricSettings - Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. +type MetricSettings struct { + // REQUIRED; a value indicating whether this category is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // 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"` + + // the retention policy for this category. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` + + // the timegrain of the metric in ISO8601 format. + TimeGrain *string `json:"timeGrain,omitempty"` +} + +// MetricSingleDimension - The metric dimension name and value. +type MetricSingleDimension struct { + // REQUIRED; Name of the dimension. + Name *string `json:"name,omitempty"` + + // REQUIRED; Value of the dimension. + Value *string `json:"value,omitempty"` +} + +// MetricTrigger - The trigger that results in a scaling action. +type MetricTrigger struct { + // REQUIRED; the name of the metric that defines what the rule monitors. + MetricName *string `json:"metricName,omitempty"` + + // REQUIRED; the resource identifier of the resource the rule monitors. + MetricResourceURI *string `json:"metricResourceUri,omitempty"` + + // REQUIRED; the operator that is used to compare the metric data and the threshold. + Operator *ComparisonOperationType `json:"operator,omitempty"` + + // REQUIRED; the metric statistic type. How the metrics from multiple instances are combined. + Statistic *MetricStatisticType `json:"statistic,omitempty"` + + // REQUIRED; the threshold of the metric that triggers the scale action. + Threshold *float64 `json:"threshold,omitempty"` + + // REQUIRED; time aggregation type. How the data that is collected should be combined over time. The default value is Average. + TimeAggregation *TimeAggregationType `json:"timeAggregation,omitempty"` + + // REQUIRED; 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"` + + // REQUIRED; 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"` + + // List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. + Dimensions []*ScaleRuleMetricDimension `json:"dimensions,omitempty"` + + // a value indicating whether metric should divide per instance. + DividePerInstance *bool `json:"dividePerInstance,omitempty"` + + // the namespace of the metric that defines what the rule monitors. + MetricNamespace *string `json:"metricNamespace,omitempty"` + + // the location of the resource the rule monitors. + MetricResourceLocation *string `json:"metricResourceLocation,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricTrigger. +func (m MetricTrigger) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "dividePerInstance", m.DividePerInstance) + populate(objectMap, "metricName", m.MetricName) + populate(objectMap, "metricNamespace", m.MetricNamespace) + populate(objectMap, "metricResourceLocation", m.MetricResourceLocation) + populate(objectMap, "metricResourceUri", m.MetricResourceURI) + populate(objectMap, "operator", m.Operator) + populate(objectMap, "statistic", m.Statistic) + populate(objectMap, "threshold", m.Threshold) + populate(objectMap, "timeAggregation", m.TimeAggregation) + populate(objectMap, "timeGrain", m.TimeGrain) + populate(objectMap, "timeWindow", m.TimeWindow) + return json.Marshal(objectMap) +} + +// MetricValue - Represents a metric value. +type MetricValue struct { + // REQUIRED; the timestamp for the metric value in ISO 8601 format. + TimeStamp *time.Time `json:"timeStamp,omitempty"` + + // the average value in the time range. + Average *float64 `json:"average,omitempty"` + + // 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"` + + // the greatest value in the time range. + Maximum *float64 `json:"maximum,omitempty"` + + // the least value in the time range. + Minimum *float64 `json:"minimum,omitempty"` + + // the sum of all of the values in the time range. + Total *float64 `json:"total,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricValue. +func (m MetricValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "average", m.Average) + populate(objectMap, "count", m.Count) + populate(objectMap, "maximum", m.Maximum) + populate(objectMap, "minimum", m.Minimum) + populate(objectMap, "timeStamp", (*timeRFC3339)(m.TimeStamp)) + populate(objectMap, "total", m.Total) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricValue. +func (m *MetricValue) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "average": + err = unpopulate(val, &m.Average) + delete(rawMsg, key) + case "count": + err = unpopulate(val, &m.Count) + delete(rawMsg, key) + case "maximum": + err = unpopulate(val, &m.Maximum) + delete(rawMsg, key) + case "minimum": + err = unpopulate(val, &m.Minimum) + delete(rawMsg, key) + case "timeStamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + m.TimeStamp = (*time.Time)(&aux) + delete(rawMsg, key) + case "total": + err = unpopulate(val, &m.Total) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MetricsListOptions contains the optional parameters for the Metrics.List method. +type MetricsListOptions struct { + // The list of aggregation types (comma separated) to retrieve. + Aggregation *string + // 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' "** + Filter *string + // The interval (i.e. timegrain) of the query. + Interval *string + // 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'** + Metricnames *string + // Metric namespace to query metric definitions for. + Metricnamespace *string + // The aggregation to use for sorting results and the direction of the sort. + // Only one order can be specified. + // Examples: sum asc. + Orderby *string + // Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. + ResultType *ResultType + // The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + Timespan *string + // The maximum number of records to retrieve. + // Valid only if $filter is specified. + // Defaults to 10. + Top *int32 +} + +// MultiMetricCriteriaClassification provides polymorphic access to related types. +// Call the interface's GetMultiMetricCriteria() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *DynamicMetricCriteria, *MetricCriteria, *MultiMetricCriteria +type MultiMetricCriteriaClassification interface { + // GetMultiMetricCriteria returns the MultiMetricCriteria content of the underlying type. + GetMultiMetricCriteria() *MultiMetricCriteria +} + +// MultiMetricCriteria - The types of conditions for a multi resource alert. +type MultiMetricCriteria struct { + // REQUIRED; Specifies the type of threshold criteria + CriterionType *CriterionType `json:"criterionType,omitempty"` + + // REQUIRED; Name of the metric. + MetricName *string `json:"metricName,omitempty"` + + // REQUIRED; Name of the criteria. + Name *string `json:"name,omitempty"` + + // REQUIRED; the criteria time aggregation types. + TimeAggregation *AggregationTypeEnum `json:"timeAggregation,omitempty"` + + // OPTIONAL; Contains additional key/value pairs not defined in the schema. + AdditionalProperties map[string]map[string]interface{} + + // List of dimension conditions. + Dimensions []*MetricDimension `json:"dimensions,omitempty"` + + // Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + + // 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"` +} + +// GetMultiMetricCriteria implements the MultiMetricCriteriaClassification interface for type MultiMetricCriteria. +func (m *MultiMetricCriteria) GetMultiMetricCriteria() *MultiMetricCriteria { return m } + +// UnmarshalJSON implements the json.Unmarshaller interface for type MultiMetricCriteria. +func (m *MultiMetricCriteria) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return m.unmarshalInternal(rawMsg) +} + +func (m MultiMetricCriteria) marshalInternal(discValue CriterionType) map[string]interface{} { + objectMap := make(map[string]interface{}) + m.CriterionType = &discValue + objectMap["criterionType"] = m.CriterionType + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "metricName", m.MetricName) + populate(objectMap, "metricNamespace", m.MetricNamespace) + populate(objectMap, "name", m.Name) + populate(objectMap, "skipMetricValidation", m.SkipMetricValidation) + populate(objectMap, "timeAggregation", m.TimeAggregation) + if m.AdditionalProperties != nil { + for key, val := range m.AdditionalProperties { + objectMap[key] = val + } + } + return objectMap +} + +func (m *MultiMetricCriteria) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "criterionType": + err = unpopulate(val, &m.CriterionType) + delete(rawMsg, key) + case "dimensions": + err = unpopulate(val, &m.Dimensions) + delete(rawMsg, key) + case "metricName": + err = unpopulate(val, &m.MetricName) + delete(rawMsg, key) + case "metricNamespace": + err = unpopulate(val, &m.MetricNamespace) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &m.Name) + delete(rawMsg, key) + case "skipMetricValidation": + err = unpopulate(val, &m.SkipMetricValidation) + delete(rawMsg, key) + case "timeAggregation": + err = unpopulate(val, &m.TimeAggregation) + delete(rawMsg, key) + default: + if m.AdditionalProperties == nil { + m.AdditionalProperties = map[string]map[string]interface{}{} + } + if val != nil { + var aux map[string]interface{} + err = json.Unmarshal(val, &aux) + m.AdditionalProperties[key] = aux + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// NetworkRuleSet - Definition of the network rules. +type NetworkRuleSet struct { + // The configuration to set whether network access from public internet to the endpoints are allowed. + PublicNetworkAccess *KnownPublicNetworkAccessOptions `json:"publicNetworkAccess,omitempty"` +} + +// Operation - Microsoft Insights API operation definition. +type Operation struct { + // Display metadata associated with the operation. + Display *OperationDisplay `json:"display,omitempty"` + + // Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` +} + +// OperationDisplay - Display metadata associated with the operation. +type OperationDisplay struct { + // Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + + // Service provider: Microsoft.Insights + Provider *string `json:"provider,omitempty"` + + // Resource on which the operation is performed: AlertRules, Autoscale, etc. + Resource *string `json:"resource,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 { + // URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // List of operations supported by the Microsoft.Insights provider. + Value []*Operation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationStatus - The status of operation. +type OperationStatus struct { + // End time of the job in standard ISO8601 format. + EndTime *time.Time `json:"endTime,omitempty"` + + // The error detail of the operation if any. + Error *ErrorResponseCommon `json:"error,omitempty"` + + // The operation Id. + ID *string `json:"id,omitempty"` + + // The operation name. + Name *string `json:"name,omitempty"` + + // Start time of the job in standard ISO8601 format. + StartTime *time.Time `json:"startTime,omitempty"` + + // The status of the operation. + Status *string `json:"status,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationStatus. +func (o OperationStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "endTime", (*timeRFC3339)(o.EndTime)) + populate(objectMap, "error", o.Error) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "startTime", (*timeRFC3339)(o.StartTime)) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatus. +func (o *OperationStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "endTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + o.EndTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "error": + err = unpopulate(val, &o.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &o.Name) + delete(rawMsg, key) + case "startTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + o.StartTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &o.Status) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// 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 { + // 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"` + + // 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"` + + // The number of seconds between consecutive counter measurements (samples). + SamplingFrequencyInSeconds *int32 `json:"samplingFrequencyInSeconds,omitempty"` + + // 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type PerfCounterDataSource. +func (p PerfCounterDataSource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "counterSpecifiers", p.CounterSpecifiers) + populate(objectMap, "name", p.Name) + populate(objectMap, "samplingFrequencyInSeconds", p.SamplingFrequencyInSeconds) + populate(objectMap, "streams", p.Streams) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnection - A private endpoint connection +type PrivateEndpointConnection struct { + ProxyResource + // Resource properties. + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// PrivateEndpointConnectionListResult - A list of private endpoint connections. +type PrivateEndpointConnectionListResult struct { + // READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Array of results. + Value []*PrivateEndpointConnection `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. +func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionProperties - Properties of a private endpoint connection. +type PrivateEndpointConnectionProperties struct { + // Private endpoint which the connection belongs to. + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` + + // Connection state of the private endpoint connection. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + + // READ-ONLY; State of the private endpoint connection. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// PrivateEndpointConnectionsBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnections.BeginCreateOrUpdate method. +type PrivateEndpointConnectionsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnections.BeginDelete method. +type PrivateEndpointConnectionsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsGetOptions contains the optional parameters for the PrivateEndpointConnections.Get method. +type PrivateEndpointConnectionsGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsListByPrivateLinkScopeOptions contains the optional parameters for the PrivateEndpointConnections.ListByPrivateLinkScope method. +type PrivateEndpointConnectionsListByPrivateLinkScopeOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointProperty - Private endpoint which the connection belongs to. +type PrivateEndpointProperty struct { + // Resource id of the private endpoint. + ID *string `json:"id,omitempty"` +} + +// PrivateLinkResource - A private link resource +type PrivateLinkResource struct { + ProxyResource + // Resource properties. + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` +} + +// PrivateLinkResourceListResult - A list of private link resources +type PrivateLinkResourceListResult struct { + // READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Array of results. + Value []*PrivateLinkResource `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. +func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceProperties - Properties of a private link resource. +type PrivateLinkResourceProperties struct { + // READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty" azure:"ro"` + + // READ-ONLY; The private link resource required member names. + RequiredMembers []*string `json:"requiredMembers,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + return json.Marshal(objectMap) +} + +// PrivateLinkResourcesGetOptions contains the optional parameters for the PrivateLinkResources.Get method. +type PrivateLinkResourcesGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResourcesListByPrivateLinkScopeOptions contains the optional parameters for the PrivateLinkResources.ListByPrivateLinkScope method. +type PrivateLinkResourcesListByPrivateLinkScopeOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopeOperationStatusGetOptions contains the optional parameters for the PrivateLinkScopeOperationStatus.Get method. +type PrivateLinkScopeOperationStatusGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopedResourcesBeginCreateOrUpdateOptions contains the optional parameters for the PrivateLinkScopedResources.BeginCreateOrUpdate method. +type PrivateLinkScopedResourcesBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopedResourcesBeginDeleteOptions contains the optional parameters for the PrivateLinkScopedResources.BeginDelete method. +type PrivateLinkScopedResourcesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopedResourcesGetOptions contains the optional parameters for the PrivateLinkScopedResources.Get method. +type PrivateLinkScopedResourcesGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopedResourcesListByPrivateLinkScopeOptions contains the optional parameters for the PrivateLinkScopedResources.ListByPrivateLinkScope method. +type PrivateLinkScopedResourcesListByPrivateLinkScopeOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesBeginDeleteOptions contains the optional parameters for the PrivateLinkScopes.BeginDelete method. +type PrivateLinkScopesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesCreateOrUpdateOptions contains the optional parameters for the PrivateLinkScopes.CreateOrUpdate method. +type PrivateLinkScopesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesGetOptions contains the optional parameters for the PrivateLinkScopes.Get method. +type PrivateLinkScopesGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesListByResourceGroupOptions contains the optional parameters for the PrivateLinkScopes.ListByResourceGroup method. +type PrivateLinkScopesListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesListOptions contains the optional parameters for the PrivateLinkScopes.List method. +type PrivateLinkScopesListOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkScopesResource - An azure resource object +type PrivateLinkScopesResource struct { + // REQUIRED; Resource location + Location *string `json:"location,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkScopesResource. +func (p PrivateLinkScopesResource) MarshalJSON() ([]byte, error) { + objectMap := p.marshalInternal() + return json.Marshal(objectMap) +} + +func (p PrivateLinkScopesResource) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return objectMap +} + +// PrivateLinkScopesUpdateTagsOptions contains the optional parameters for the PrivateLinkScopes.UpdateTags method. +type PrivateLinkScopesUpdateTagsOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkServiceConnectionStateProperty - State of the private endpoint connection. +type PrivateLinkServiceConnectionStateProperty struct { + // REQUIRED; The private link service connection description. + Description *string `json:"description,omitempty"` + + // REQUIRED; The private link service connection status. + Status *string `json:"status,omitempty"` + + // READ-ONLY; The actions required for private link service connection. + ActionsRequired *string `json:"actionsRequired,omitempty" azure:"ro"` +} + +// ProxyOnlyResource - A proxy only azure resource object +type ProxyOnlyResource struct { + // READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ProxyResource - An azure resource object +type ProxyResource struct { + // READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// Recurrence - The repeating times at which this profile begins. This element is not used if the FixedDate element is used. +type Recurrence struct { + // REQUIRED; 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. + Frequency *RecurrenceFrequency `json:"frequency,omitempty"` + + // REQUIRED; 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 { + // REQUIRED; the collection of days that the profile takes effect on. Possible values are Sunday through Saturday. + Days []*string `json:"days,omitempty"` + + // REQUIRED; 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"` + + // REQUIRED; A collection of minutes at which the profile takes effect at. + Minutes []*int32 `json:"minutes,omitempty"` + + // REQUIRED; 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type RecurrentSchedule. +func (r RecurrentSchedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "days", r.Days) + populate(objectMap, "hours", r.Hours) + populate(objectMap, "minutes", r.Minutes) + populate(objectMap, "timeZone", r.TimeZone) + return json.Marshal(objectMap) +} + +// Resource - An azure resource object +type Resource struct { + // REQUIRED; Resource location + Location *string `json:"location,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := r.marshalInternal() + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return objectMap +} + +// ResourceForUpdate - Definition of ARM tracked top level resource properties for update operation. +type ResourceForUpdate struct { + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceForUpdate. +func (r ResourceForUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// Response - The response to a metrics query. +type Response struct { + // REQUIRED; 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"` + + // REQUIRED; the value of the collection. + Value []*Metric `json:"value,omitempty"` + + // The integer value representing the relative cost of the query. + Cost *int32 `json:"cost,omitempty"` + + // 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"` + + // The namespace of the metrics being queried + Namespace *string `json:"namespace,omitempty"` + + // The region of the resource being queried for metrics. + Resourceregion *string `json:"resourceregion,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Response. +func (r Response) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "cost", r.Cost) + populate(objectMap, "interval", r.Interval) + populate(objectMap, "namespace", r.Namespace) + populate(objectMap, "resourceregion", r.Resourceregion) + populate(objectMap, "timespan", r.Timespan) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// ResponseWithError - An error response from the API. +// Implements the error and azcore.HTTPResponse interfaces. +type ResponseWithError struct { + raw string + // REQUIRED; Error information. + InnerError *Error `json:"error,omitempty"` +} + +// Error implements the error interface for type ResponseWithError. +// The contents of the error text are not contractual and subject to change. +func (e ResponseWithError) Error() string { + return e.raw +} + +// RetentionPolicy - Specifies the retention policy for the log. +type RetentionPolicy struct { + // REQUIRED; the number of days for the retention in days. A value of 0 will retain the events indefinitely. + Days *int32 `json:"days,omitempty"` + + // REQUIRED; a value indicating whether the retention policy is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// RuleActionClassification provides polymorphic access to related types. +// Call the interface's GetRuleAction() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *RuleAction, *RuleEmailAction, *RuleWebhookAction +type RuleActionClassification interface { + // GetRuleAction returns the RuleAction content of the underlying type. + GetRuleAction() *RuleAction +} + +// RuleAction - The action that is performed when the alert rule becomes active, and when an alert condition is resolved. +type RuleAction struct { + // REQUIRED; specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction. + OdataType *string `json:"odata.type,omitempty"` +} + +// GetRuleAction implements the RuleActionClassification interface for type RuleAction. +func (r *RuleAction) GetRuleAction() *RuleAction { return r } + +// UnmarshalJSON implements the json.Unmarshaller interface for type RuleAction. +func (r *RuleAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return r.unmarshalInternal(rawMsg) +} + +func (r RuleAction) marshalInternal(discValue string) map[string]interface{} { + objectMap := make(map[string]interface{}) + r.OdataType = &discValue + objectMap["odata.type"] = r.OdataType + return objectMap +} + +func (r *RuleAction) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "odata.type": + err = unpopulate(val, &r.OdataType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// RuleConditionClassification provides polymorphic access to related types. +// Call the interface's GetRuleCondition() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *LocationThresholdRuleCondition, *ManagementEventRuleCondition, *RuleCondition, *ThresholdRuleCondition +type RuleConditionClassification interface { + // GetRuleCondition returns the RuleCondition content of the underlying type. + GetRuleCondition() *RuleCondition +} + +// RuleCondition - The condition that results in the alert rule being activated. +type RuleCondition struct { + // REQUIRED; specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition + // (based on the number of failures of a + // web test), and ThresholdRuleCondition (based on the threshold of a metric). + OdataType *string `json:"odata.type,omitempty"` + + // the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource RuleDataSourceClassification `json:"dataSource,omitempty"` +} + +// GetRuleCondition implements the RuleConditionClassification interface for type RuleCondition. +func (r *RuleCondition) GetRuleCondition() *RuleCondition { return r } + +// UnmarshalJSON implements the json.Unmarshaller interface for type RuleCondition. +func (r *RuleCondition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return r.unmarshalInternal(rawMsg) +} + +func (r RuleCondition) marshalInternal(discValue string) map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "dataSource", r.DataSource) + r.OdataType = &discValue + objectMap["odata.type"] = r.OdataType + return objectMap +} + +func (r *RuleCondition) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "dataSource": + r.DataSource, err = unmarshalRuleDataSourceClassification(val) + delete(rawMsg, key) + case "odata.type": + err = unpopulate(val, &r.OdataType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// RuleDataSourceClassification provides polymorphic access to related types. +// Call the interface's GetRuleDataSource() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *RuleDataSource, *RuleManagementEventDataSource, *RuleMetricDataSource +type RuleDataSourceClassification interface { + // GetRuleDataSource returns the RuleDataSource content of the underlying type. + GetRuleDataSource() *RuleDataSource +} + +// RuleDataSource - The resource from which the rule collects its data. +type RuleDataSource struct { + // REQUIRED; specifies the type of data source. There are two types of rule data sources: RuleMetricDataSource and RuleManagementEventDataSource + OdataType *string `json:"odata.type,omitempty"` + + // 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"` + + // the namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + + // the location of the resource. + ResourceLocation *string `json:"resourceLocation,omitempty"` + + // the resource identifier of the resource the rule monitors. NOTE: this property cannot be updated for an existing rule. + ResourceURI *string `json:"resourceUri,omitempty"` +} + +// GetRuleDataSource implements the RuleDataSourceClassification interface for type RuleDataSource. +func (r *RuleDataSource) GetRuleDataSource() *RuleDataSource { return r } + +// UnmarshalJSON implements the json.Unmarshaller interface for type RuleDataSource. +func (r *RuleDataSource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return r.unmarshalInternal(rawMsg) +} + +func (r RuleDataSource) marshalInternal(discValue string) map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "legacyResourceId", r.LegacyResourceID) + populate(objectMap, "metricNamespace", r.MetricNamespace) + r.OdataType = &discValue + objectMap["odata.type"] = r.OdataType + populate(objectMap, "resourceLocation", r.ResourceLocation) + populate(objectMap, "resourceUri", r.ResourceURI) + return objectMap +} + +func (r *RuleDataSource) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "legacyResourceId": + err = unpopulate(val, &r.LegacyResourceID) + delete(rawMsg, key) + case "metricNamespace": + err = unpopulate(val, &r.MetricNamespace) + delete(rawMsg, key) + case "odata.type": + err = unpopulate(val, &r.OdataType) + delete(rawMsg, key) + case "resourceLocation": + err = unpopulate(val, &r.ResourceLocation) + delete(rawMsg, key) + case "resourceUri": + err = unpopulate(val, &r.ResourceURI) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// RuleEmailAction - Specifies the action to send email when the rule condition is evaluated. The discriminator is always RuleEmailAction in this case. +type RuleEmailAction struct { + RuleAction + // the list of administrator's custom email addresses to notify of the activation of the alert. + CustomEmails []*string `json:"customEmails,omitempty"` + + // Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. + SendToServiceOwners *bool `json:"sendToServiceOwners,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RuleEmailAction. +func (r RuleEmailAction) MarshalJSON() ([]byte, error) { + objectMap := r.RuleAction.marshalInternal("Microsoft.Azure.Management.Insights.Models.RuleEmailAction") + populate(objectMap, "customEmails", r.CustomEmails) + populate(objectMap, "sendToServiceOwners", r.SendToServiceOwners) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RuleEmailAction. +func (r *RuleEmailAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "customEmails": + err = unpopulate(val, &r.CustomEmails) + delete(rawMsg, key) + case "sendToServiceOwners": + err = unpopulate(val, &r.SendToServiceOwners) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return r.RuleAction.unmarshalInternal(rawMsg) +} + +// RuleManagementEventClaimsDataSource - The claims for a rule management event data source. +type RuleManagementEventClaimsDataSource struct { + // 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 { + RuleDataSource + // the claims. + Claims *RuleManagementEventClaimsDataSource `json:"claims,omitempty"` + + // the event name. + EventName *string `json:"eventName,omitempty"` + + // the event source. + EventSource *string `json:"eventSource,omitempty"` + + // the level. + Level *string `json:"level,omitempty"` + + // The name of the operation that should be checked for. If no name is provided, any operation will match. + OperationName *string `json:"operationName,omitempty"` + + // the resource group name. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + + // the resource provider name. + ResourceProviderName *string `json:"resourceProviderName,omitempty"` + + // The status of the operation that should be checked for. If no status is provided, any status will match. + Status *string `json:"status,omitempty"` + + // the substatus. + SubStatus *string `json:"subStatus,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RuleManagementEventDataSource. +func (r RuleManagementEventDataSource) MarshalJSON() ([]byte, error) { + objectMap := r.RuleDataSource.marshalInternal("Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource") + populate(objectMap, "claims", r.Claims) + populate(objectMap, "eventName", r.EventName) + populate(objectMap, "eventSource", r.EventSource) + populate(objectMap, "level", r.Level) + populate(objectMap, "operationName", r.OperationName) + populate(objectMap, "resourceGroupName", r.ResourceGroupName) + populate(objectMap, "resourceProviderName", r.ResourceProviderName) + populate(objectMap, "status", r.Status) + populate(objectMap, "subStatus", r.SubStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RuleManagementEventDataSource. +func (r *RuleManagementEventDataSource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "claims": + err = unpopulate(val, &r.Claims) + delete(rawMsg, key) + case "eventName": + err = unpopulate(val, &r.EventName) + delete(rawMsg, key) + case "eventSource": + err = unpopulate(val, &r.EventSource) + delete(rawMsg, key) + case "level": + err = unpopulate(val, &r.Level) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, &r.OperationName) + delete(rawMsg, key) + case "resourceGroupName": + err = unpopulate(val, &r.ResourceGroupName) + delete(rawMsg, key) + case "resourceProviderName": + err = unpopulate(val, &r.ResourceProviderName) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &r.Status) + delete(rawMsg, key) + case "subStatus": + err = unpopulate(val, &r.SubStatus) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return r.RuleDataSource.unmarshalInternal(rawMsg) +} + +// RuleMetricDataSource - A rule metric data source. The discriminator value is always RuleMetricDataSource in this case. +type RuleMetricDataSource struct { + RuleDataSource + // the name of the metric that defines what the rule monitors. + MetricName *string `json:"metricName,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RuleMetricDataSource. +func (r RuleMetricDataSource) MarshalJSON() ([]byte, error) { + objectMap := r.RuleDataSource.marshalInternal("Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource") + populate(objectMap, "metricName", r.MetricName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RuleMetricDataSource. +func (r *RuleMetricDataSource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "metricName": + err = unpopulate(val, &r.MetricName) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return r.RuleDataSource.unmarshalInternal(rawMsg) +} + +// 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 { + RuleAction + // 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,omitempty"` + + // the service uri to Post the notification when the alert activates or resolves. + ServiceURI *string `json:"serviceUri,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RuleWebhookAction. +func (r RuleWebhookAction) MarshalJSON() ([]byte, error) { + objectMap := r.RuleAction.marshalInternal("Microsoft.Azure.Management.Insights.Models.RuleWebhookAction") + populate(objectMap, "properties", r.Properties) + populate(objectMap, "serviceUri", r.ServiceURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RuleWebhookAction. +func (r *RuleWebhookAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, &r.Properties) + delete(rawMsg, key) + case "serviceUri": + err = unpopulate(val, &r.ServiceURI) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return r.RuleAction.unmarshalInternal(rawMsg) +} + +// ScaleAction - The parameters for the scaling action. +type ScaleAction struct { + // REQUIRED; 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"` + + // REQUIRED; the scale direction. Whether the scaling action increases or decreases the number of instances. + Direction *ScaleDirection `json:"direction,omitempty"` + + // REQUIRED; the type of action that should occur when the scale rule fires. + Type *ScaleType `json:"type,omitempty"` + + // 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"` +} + +// ScaleCapacity - The number of instances that can be used during this profile. +type ScaleCapacity struct { + // REQUIRED; 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"` + + // REQUIRED; 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"` + + // REQUIRED; the minimum number of instances for the resource. + Minimum *string `json:"minimum,omitempty"` +} + +// ScaleRule - A rule that provide the triggers and parameters for the scaling action. +type ScaleRule struct { + // REQUIRED; the trigger that results in a scaling action. + MetricTrigger *MetricTrigger `json:"metricTrigger,omitempty"` + + // REQUIRED; the parameters for the scaling action. + ScaleAction *ScaleAction `json:"scaleAction,omitempty"` +} + +// ScaleRuleMetricDimension - Specifies an auto scale rule metric dimension. +type ScaleRuleMetricDimension struct { + // REQUIRED; Name of the dimension. + DimensionName *string `json:"DimensionName,omitempty"` + + // REQUIRED; 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 + Operator *ScaleRuleMetricDimensionOperationType `json:"Operator,omitempty"` + + // REQUIRED; list of dimension values. For example: ["App1","App2"]. + Values []*string `json:"Values,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScaleRuleMetricDimension. +func (s ScaleRuleMetricDimension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "DimensionName", s.DimensionName) + populate(objectMap, "Operator", s.Operator) + populate(objectMap, "Values", s.Values) + return json.Marshal(objectMap) +} + +// Schedule - Defines how often to run the search and the time interval. +type Schedule struct { + // REQUIRED; frequency (in minutes) at which rule condition should be evaluated. + FrequencyInMinutes *int32 `json:"frequencyInMinutes,omitempty"` + + // REQUIRED; Time window for which data needs to be fetched for query (should be greater than or equal to frequencyInMinutes). + TimeWindowInMinutes *int32 `json:"timeWindowInMinutes,omitempty"` +} + +// ScheduledQueryRulesCreateOrUpdateOptions contains the optional parameters for the ScheduledQueryRules.CreateOrUpdate method. +type ScheduledQueryRulesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ScheduledQueryRulesDeleteOptions contains the optional parameters for the ScheduledQueryRules.Delete method. +type ScheduledQueryRulesDeleteOptions struct { + // placeholder for future optional parameters +} + +// ScheduledQueryRulesGetOptions contains the optional parameters for the ScheduledQueryRules.Get method. +type ScheduledQueryRulesGetOptions struct { + // placeholder for future optional parameters +} + +// ScheduledQueryRulesListByResourceGroupOptions contains the optional parameters for the ScheduledQueryRules.ListByResourceGroup method. +type ScheduledQueryRulesListByResourceGroupOptions struct { + // The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + Filter *string +} + +// ScheduledQueryRulesListBySubscriptionOptions contains the optional parameters for the ScheduledQueryRules.ListBySubscription method. +type ScheduledQueryRulesListBySubscriptionOptions struct { + // The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + Filter *string +} + +// ScheduledQueryRulesUpdateOptions contains the optional parameters for the ScheduledQueryRules.Update method. +type ScheduledQueryRulesUpdateOptions struct { + // placeholder for future optional parameters +} + +// ScopedResource - A private link scoped resource +type ScopedResource struct { + ProxyResource + // Resource properties. + Properties *ScopedResourceProperties `json:"properties,omitempty"` +} + +// ScopedResourceListResult - A list of scoped resources in a private link scope. +type ScopedResourceListResult struct { + // READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Array of results. + Value []*ScopedResource `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScopedResourceListResult. +func (s ScopedResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// ScopedResourceProperties - Properties of a private link scoped resource. +type ScopedResourceProperties struct { + // The resource id of the scoped Azure monitor resource. + LinkedResourceID *string `json:"linkedResourceId,omitempty"` + + // READ-ONLY; State of the private endpoint connection. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// 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 { + // the permissible actions. For instance: microsoft.support/supporttickets/write + Action *string `json:"action,omitempty"` + + // the role of the user. For instance: Subscription Admin + Role *string `json:"role,omitempty"` + + // the scope. + Scope *string `json:"scope,omitempty"` +} + +// SingleBaseline - The baseline values for a single sensitivity value. +type SingleBaseline struct { + // REQUIRED; The high thresholds of the baseline. + HighThresholds []*float64 `json:"highThresholds,omitempty"` + + // REQUIRED; The low thresholds of the baseline. + LowThresholds []*float64 `json:"lowThresholds,omitempty"` + + // REQUIRED; the sensitivity of the baseline. + Sensitivity *BaselineSensitivity `json:"sensitivity,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SingleBaseline. +func (s SingleBaseline) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "highThresholds", s.HighThresholds) + populate(objectMap, "lowThresholds", s.LowThresholds) + populate(objectMap, "sensitivity", s.Sensitivity) + return json.Marshal(objectMap) +} + +// SingleMetricBaseline - The baseline results of a single metric. +type SingleMetricBaseline struct { + // REQUIRED; The metric baseline Id. + ID *string `json:"id,omitempty"` + + // REQUIRED; The name of the metric for which the baselines were retrieved. + Name *string `json:"name,omitempty"` + + // REQUIRED; The metric baseline properties of the metric. + Properties *MetricBaselinesProperties `json:"properties,omitempty"` + + // REQUIRED; The resource type of the metric baseline resource. + Type *string `json:"type,omitempty"` +} + +// SmsReceiver - An SMS receiver. +type SmsReceiver struct { + // REQUIRED; The country code of the SMS receiver. + CountryCode *string `json:"countryCode,omitempty"` + + // REQUIRED; The name of the SMS receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + + // REQUIRED; The phone number of the SMS receiver. + PhoneNumber *string `json:"phoneNumber,omitempty"` + + // READ-ONLY; The status of the receiver. + Status *ReceiverStatus `json:"status,omitempty" azure:"ro"` +} + +// Source - Specifies the log search query. +type Source struct { + // REQUIRED; The resource uri over which log search query is to be run. + DataSourceID *string `json:"dataSourceId,omitempty"` + + // List of Resource referred into query + AuthorizedResources []*string `json:"authorizedResources,omitempty"` + + // Log search query. Required for action type - AlertingAction + Query *string `json:"query,omitempty"` + + // Set value to 'ResultCount' . + QueryType *QueryType `json:"queryType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Source. +func (s Source) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authorizedResources", s.AuthorizedResources) + populate(objectMap, "dataSourceId", s.DataSourceID) + populate(objectMap, "query", s.Query) + populate(objectMap, "queryType", s.QueryType) + return json.Marshal(objectMap) +} + +// SyslogDataSource - Definition of which syslog data will be collected and how it will be collected. Only collected from Linux machines. +type SyslogDataSource struct { + // The list of facility names. + FacilityNames []*KnownSyslogDataSourceFacilityNames `json:"facilityNames,omitempty"` + + // The log levels to collect. + LogLevels []*KnownSyslogDataSourceLogLevels `json:"logLevels,omitempty"` + + // 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"` + + // 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type SyslogDataSource. +func (s SyslogDataSource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "facilityNames", s.FacilityNames) + populate(objectMap, "logLevels", s.LogLevels) + populate(objectMap, "name", s.Name) + populate(objectMap, "streams", s.Streams) + return json.Marshal(objectMap) +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := s.marshalInternal() + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return s.unmarshalInternal(rawMsg) +} + +func (s SystemData) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "createdAt", (*timeRFC3339)(s.CreatedAt)) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populate(objectMap, "lastModifiedAt", (*timeRFC3339)(s.LastModifiedAt)) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return objectMap +} + +func (s *SystemData) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.CreatedAt = (*time.Time)(&aux) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.LastModifiedAt = (*time.Time)(&aux) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TagsResource - A container holding only the Tags for a resource, allowing the user to update the tags on a PrivateLinkScope instance. +type TagsResource struct { + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TagsResource. +func (t TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// TenantActivityLogsListOptions contains the optional parameters for the TenantActivityLogs.List method. +type TenantActivityLogsListOptions struct { + // 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. + Filter *string + // 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* + Select *string +} + +// ThresholdRuleCondition - A rule condition based on a metric crossing a threshold. +type ThresholdRuleCondition struct { + RuleCondition + // REQUIRED; the operator used to compare the data and the threshold. + Operator *ConditionOperator `json:"operator,omitempty"` + + // REQUIRED; the threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + + // the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. + TimeAggregation *TimeAggregationOperator `json:"timeAggregation,omitempty"` + + // 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type ThresholdRuleCondition. +func (t ThresholdRuleCondition) MarshalJSON() ([]byte, error) { + objectMap := t.RuleCondition.marshalInternal("Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition") + populate(objectMap, "operator", t.Operator) + populate(objectMap, "threshold", t.Threshold) + populate(objectMap, "timeAggregation", t.TimeAggregation) + populate(objectMap, "windowSize", t.WindowSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ThresholdRuleCondition. +func (t *ThresholdRuleCondition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "operator": + err = unpopulate(val, &t.Operator) + delete(rawMsg, key) + case "threshold": + err = unpopulate(val, &t.Threshold) + delete(rawMsg, key) + case "timeAggregation": + err = unpopulate(val, &t.TimeAggregation) + delete(rawMsg, key) + case "windowSize": + err = unpopulate(val, &t.WindowSize) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return t.RuleCondition.unmarshalInternal(rawMsg) +} + +// TimeSeriesBaseline - The baseline values for a single time series. +type TimeSeriesBaseline struct { + // REQUIRED; The aggregation type of the metric. + Aggregation *string `json:"aggregation,omitempty"` + + // REQUIRED; The baseline values for each sensitivity. + Data []*SingleBaseline `json:"data,omitempty"` + + // REQUIRED; The list of timestamps of the baselines. + Timestamps []*time.Time `json:"timestamps,omitempty"` + + // The dimensions of this time series. + Dimensions []*MetricSingleDimension `json:"dimensions,omitempty"` + + // The baseline metadata values. + MetadataValues []*BaselineMetadata `json:"metadataValues,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TimeSeriesBaseline. +func (t TimeSeriesBaseline) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregation", t.Aggregation) + populate(objectMap, "data", t.Data) + populate(objectMap, "dimensions", t.Dimensions) + populate(objectMap, "metadataValues", t.MetadataValues) + populate(objectMap, "timestamps", t.Timestamps) + return json.Marshal(objectMap) +} + +// TimeSeriesElement - A time series result type. The discriminator value is always TimeSeries in this case. +type TimeSeriesElement struct { + // 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"` + + // the metadata values returned if $filter was specified in the call. + Metadatavalues []*MetadataValue `json:"metadatavalues,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TimeSeriesElement. +func (t TimeSeriesElement) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "data", t.Data) + populate(objectMap, "metadatavalues", t.Metadatavalues) + return json.Marshal(objectMap) +} + +// TimeWindow - A specific date-time for the profile. +type TimeWindow struct { + // REQUIRED; the end time for the profile in ISO 8601 format. + End *time.Time `json:"end,omitempty"` + + // REQUIRED; the start time for the profile in ISO 8601 format. + Start *time.Time `json:"start,omitempty"` + + // 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type TimeWindow. +func (t TimeWindow) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "end", (*timeRFC3339)(t.End)) + populate(objectMap, "start", (*timeRFC3339)(t.Start)) + populate(objectMap, "timeZone", t.TimeZone) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TimeWindow. +func (t *TimeWindow) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "end": + var aux timeRFC3339 + err = unpopulate(val, &aux) + t.End = (*time.Time)(&aux) + delete(rawMsg, key) + case "start": + var aux timeRFC3339 + err = unpopulate(val, &aux) + t.Start = (*time.Time)(&aux) + delete(rawMsg, key) + case "timeZone": + err = unpopulate(val, &t.TimeZone) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TrackedEntityResource - An azure resource object +type TrackedEntityResource struct { + // REQUIRED; Resource location + Location *string `json:"location,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // 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" azure:"ro"` + + // READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // 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" azure:"ro"` + + // READ-ONLY; Azure resource name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedEntityResource. +func (t TrackedEntityResource) MarshalJSON() ([]byte, error) { + objectMap := t.marshalInternal() + return json.Marshal(objectMap) +} + +func (t TrackedEntityResource) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "etag", t.Etag) + populate(objectMap, "id", t.ID) + populate(objectMap, "kind", t.Kind) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return objectMap +} + +// TriggerCondition - The condition that results in the Log Search rule. +type TriggerCondition struct { + // REQUIRED; Result or count threshold based on which rule should be triggered. + Threshold *float64 `json:"threshold,omitempty"` + + // REQUIRED; Evaluation operation for rule - 'GreaterThan' or 'LessThan. + ThresholdOperator *ConditionalOperator `json:"thresholdOperator,omitempty"` + + // Trigger condition for metric query rule + MetricTrigger *LogMetricTrigger `json:"metricTrigger,omitempty"` +} + +// VMInsightsGetOnboardingStatusOptions contains the optional parameters for the VMInsights.GetOnboardingStatus method. +type VMInsightsGetOnboardingStatusOptions struct { + // placeholder for future optional parameters +} + +// VMInsightsOnboardingStatus - VM Insights onboarding status for a resource. +type VMInsightsOnboardingStatus struct { + ProxyResource + // Resource properties. + Properties *VMInsightsOnboardingStatusProperties `json:"properties,omitempty"` +} + +// VMInsightsOnboardingStatusProperties - Resource properties. +type VMInsightsOnboardingStatusProperties struct { + // REQUIRED; 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. + DataStatus *DataStatus `json:"dataStatus,omitempty"` + + // REQUIRED; 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. + OnboardingStatus *OnboardingStatus `json:"onboardingStatus,omitempty"` + + // REQUIRED; Azure Resource Manager identifier of the resource whose onboarding status is being represented. + ResourceID *string `json:"resourceId,omitempty"` + + // Containers that currently store VM Insights data for the specified resource. + Data []*DataContainer `json:"data,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VMInsightsOnboardingStatusProperties. +func (v VMInsightsOnboardingStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "data", v.Data) + populate(objectMap, "dataStatus", v.DataStatus) + populate(objectMap, "onboardingStatus", v.OnboardingStatus) + populate(objectMap, "resourceId", v.ResourceID) + return json.Marshal(objectMap) +} + +// VoiceReceiver - A voice receiver. +type VoiceReceiver struct { + // REQUIRED; The country code of the voice receiver. + CountryCode *string `json:"countryCode,omitempty"` + + // REQUIRED; The name of the voice receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + + // REQUIRED; The phone number of the voice receiver. + PhoneNumber *string `json:"phoneNumber,omitempty"` +} + +// WebhookNotification - Webhook notification of an autoscale event. +type WebhookNotification struct { + // a property bag of settings. This value can be empty. + Properties map[string]*string `json:"properties,omitempty"` + + // the service address to receive the notification. + ServiceURI *string `json:"serviceUri,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WebhookNotification. +func (w WebhookNotification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "serviceUri", w.ServiceURI) + return json.Marshal(objectMap) +} + +// WebhookReceiver - A webhook receiver. +type WebhookReceiver struct { + // REQUIRED; The name of the webhook receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + + // REQUIRED; The URI where webhooks should be sent. + ServiceURI *string `json:"serviceUri,omitempty"` + + // Indicates the identifier uri for aad auth. + IdentifierURI *string `json:"identifierUri,omitempty"` + + // Indicates the webhook app object Id for aad auth. + ObjectID *string `json:"objectId,omitempty"` + + // Indicates the tenant id for aad auth. + TenantID *string `json:"tenantId,omitempty"` + + // Indicates whether or not use AAD authentication. + UseAADAuth *bool `json:"useAadAuth,omitempty"` + + // Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// WebtestLocationAvailabilityCriteria - Specifies the metric alert rule criteria for a web test resource. +type WebtestLocationAvailabilityCriteria struct { + MetricAlertCriteria + // REQUIRED; The Application Insights resource Id. + ComponentID *string `json:"componentId,omitempty"` + + // REQUIRED; The number of failed locations. + FailedLocationCount *float32 `json:"failedLocationCount,omitempty"` + + // REQUIRED; The Application Insights web test Id. + WebTestID *string `json:"webTestId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WebtestLocationAvailabilityCriteria. +func (w WebtestLocationAvailabilityCriteria) MarshalJSON() ([]byte, error) { + objectMap := w.MetricAlertCriteria.marshalInternal(OdatatypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria) + populate(objectMap, "componentId", w.ComponentID) + populate(objectMap, "failedLocationCount", w.FailedLocationCount) + populate(objectMap, "webTestId", w.WebTestID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebtestLocationAvailabilityCriteria. +func (w *WebtestLocationAvailabilityCriteria) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "componentId": + err = unpopulate(val, &w.ComponentID) + delete(rawMsg, key) + case "failedLocationCount": + err = unpopulate(val, &w.FailedLocationCount) + delete(rawMsg, key) + case "webTestId": + err = unpopulate(val, &w.WebTestID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return w.MetricAlertCriteria.unmarshalInternal(rawMsg) +} + +// 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 { + // 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"` + + // 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"` + + // A list of Windows Event Log queries in XPATH format. + XPathQueries []*string `json:"xPathQueries,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WindowsEventLogDataSource. +func (w WindowsEventLogDataSource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", w.Name) + populate(objectMap, "streams", w.Streams) + populate(objectMap, "xPathQueries", w.XPathQueries) + return json.Marshal(objectMap) +} + +// WorkspaceInfo - Information about a Log Analytics Workspace. +type WorkspaceInfo struct { + // REQUIRED; Azure Resource Manager identifier of the Log Analytics Workspace. + ID *string `json:"id,omitempty"` + + // REQUIRED; Location of the Log Analytics workspace. + Location *string `json:"location,omitempty"` + + // REQUIRED; Resource properties. + Properties *WorkspaceInfoProperties `json:"properties,omitempty"` +} + +// WorkspaceInfoProperties - Resource properties. +type WorkspaceInfoProperties struct { + // REQUIRED; Log Analytics workspace identifier. + CustomerID *string `json:"customerId,omitempty"` +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/monitor/armmonitor/zz_generated_operations_client.go b/sdk/monitor/armmonitor/zz_generated_operations_client.go new file mode 100644 index 000000000000..3b606a594462 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_operations_client.go @@ -0,0 +1,80 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + con *armcore.Connection +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(con *armcore.Connection) *OperationsClient { + return &OperationsClient{con: con} +} + +// List - Lists all of the available operations from Microsoft.Insights provider. +// If the operation fails it returns a generic error. +func (client *OperationsClient) List(ctx context.Context, options *OperationsListOptions) (OperationListResultResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return OperationListResultResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return OperationListResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return OperationListResultResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*azcore.Request, error) { + urlPath := "/providers/Microsoft.Insights/operations" + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2015-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *azcore.Response) (OperationListResultResponse, error) { + var val *OperationListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return OperationListResultResponse{}, err + } + return OperationListResultResponse{RawResponse: resp.Response, OperationListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_pagers.go b/sdk/monitor/armmonitor/zz_generated_pagers.go new file mode 100644 index 000000000000..9e4a8577a356 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_pagers.go @@ -0,0 +1,698 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// AutoscaleSettingResourceCollectionPager provides iteration over AutoscaleSettingResourceCollection pages. +type AutoscaleSettingResourceCollectionPager interface { + azcore.Pager + + // PageResponse returns the current AutoscaleSettingResourceCollectionResponse. + PageResponse() AutoscaleSettingResourceCollectionResponse +} + +type autoscaleSettingResourceCollectionCreateRequest func(context.Context) (*azcore.Request, error) + +type autoscaleSettingResourceCollectionHandleError func(*azcore.Response) error + +type autoscaleSettingResourceCollectionHandleResponse func(*azcore.Response) (AutoscaleSettingResourceCollectionResponse, error) + +type autoscaleSettingResourceCollectionAdvancePage func(context.Context, AutoscaleSettingResourceCollectionResponse) (*azcore.Request, error) + +type autoscaleSettingResourceCollectionPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester autoscaleSettingResourceCollectionCreateRequest + // callback for handling response errors + errorer autoscaleSettingResourceCollectionHandleError + // callback for handling the HTTP response + responder autoscaleSettingResourceCollectionHandleResponse + // callback for advancing to the next page + advancer autoscaleSettingResourceCollectionAdvancePage + // contains the current response + current AutoscaleSettingResourceCollectionResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *autoscaleSettingResourceCollectionPager) Err() error { + return p.err +} + +func (p *autoscaleSettingResourceCollectionPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AutoscaleSettingResourceCollection.NextLink == nil || len(*p.current.AutoscaleSettingResourceCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *autoscaleSettingResourceCollectionPager) PageResponse() AutoscaleSettingResourceCollectionResponse { + return p.current +} + +// AzureMonitorPrivateLinkScopeListResultPager provides iteration over AzureMonitorPrivateLinkScopeListResult pages. +type AzureMonitorPrivateLinkScopeListResultPager interface { + azcore.Pager + + // PageResponse returns the current AzureMonitorPrivateLinkScopeListResultResponse. + PageResponse() AzureMonitorPrivateLinkScopeListResultResponse +} + +type azureMonitorPrivateLinkScopeListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type azureMonitorPrivateLinkScopeListResultHandleError func(*azcore.Response) error + +type azureMonitorPrivateLinkScopeListResultHandleResponse func(*azcore.Response) (AzureMonitorPrivateLinkScopeListResultResponse, error) + +type azureMonitorPrivateLinkScopeListResultAdvancePage func(context.Context, AzureMonitorPrivateLinkScopeListResultResponse) (*azcore.Request, error) + +type azureMonitorPrivateLinkScopeListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester azureMonitorPrivateLinkScopeListResultCreateRequest + // callback for handling response errors + errorer azureMonitorPrivateLinkScopeListResultHandleError + // callback for handling the HTTP response + responder azureMonitorPrivateLinkScopeListResultHandleResponse + // callback for advancing to the next page + advancer azureMonitorPrivateLinkScopeListResultAdvancePage + // contains the current response + current AzureMonitorPrivateLinkScopeListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *azureMonitorPrivateLinkScopeListResultPager) Err() error { + return p.err +} + +func (p *azureMonitorPrivateLinkScopeListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AzureMonitorPrivateLinkScopeListResult.NextLink == nil || len(*p.current.AzureMonitorPrivateLinkScopeListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *azureMonitorPrivateLinkScopeListResultPager) PageResponse() AzureMonitorPrivateLinkScopeListResultResponse { + return p.current +} + +// DataCollectionEndpointResourceListResultPager provides iteration over DataCollectionEndpointResourceListResult pages. +type DataCollectionEndpointResourceListResultPager interface { + azcore.Pager + + // PageResponse returns the current DataCollectionEndpointResourceListResultResponse. + PageResponse() DataCollectionEndpointResourceListResultResponse +} + +type dataCollectionEndpointResourceListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type dataCollectionEndpointResourceListResultHandleError func(*azcore.Response) error + +type dataCollectionEndpointResourceListResultHandleResponse func(*azcore.Response) (DataCollectionEndpointResourceListResultResponse, error) + +type dataCollectionEndpointResourceListResultAdvancePage func(context.Context, DataCollectionEndpointResourceListResultResponse) (*azcore.Request, error) + +type dataCollectionEndpointResourceListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester dataCollectionEndpointResourceListResultCreateRequest + // callback for handling response errors + errorer dataCollectionEndpointResourceListResultHandleError + // callback for handling the HTTP response + responder dataCollectionEndpointResourceListResultHandleResponse + // callback for advancing to the next page + advancer dataCollectionEndpointResourceListResultAdvancePage + // contains the current response + current DataCollectionEndpointResourceListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *dataCollectionEndpointResourceListResultPager) Err() error { + return p.err +} + +func (p *dataCollectionEndpointResourceListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DataCollectionEndpointResourceListResult.NextLink == nil || len(*p.current.DataCollectionEndpointResourceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *dataCollectionEndpointResourceListResultPager) PageResponse() DataCollectionEndpointResourceListResultResponse { + return p.current +} + +// DataCollectionRuleAssociationProxyOnlyResourceListResultPager provides iteration over DataCollectionRuleAssociationProxyOnlyResourceListResult pages. +type DataCollectionRuleAssociationProxyOnlyResourceListResultPager interface { + azcore.Pager + + // PageResponse returns the current DataCollectionRuleAssociationProxyOnlyResourceListResultResponse. + PageResponse() DataCollectionRuleAssociationProxyOnlyResourceListResultResponse +} + +type dataCollectionRuleAssociationProxyOnlyResourceListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type dataCollectionRuleAssociationProxyOnlyResourceListResultHandleError func(*azcore.Response) error + +type dataCollectionRuleAssociationProxyOnlyResourceListResultHandleResponse func(*azcore.Response) (DataCollectionRuleAssociationProxyOnlyResourceListResultResponse, error) + +type dataCollectionRuleAssociationProxyOnlyResourceListResultAdvancePage func(context.Context, DataCollectionRuleAssociationProxyOnlyResourceListResultResponse) (*azcore.Request, error) + +type dataCollectionRuleAssociationProxyOnlyResourceListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester dataCollectionRuleAssociationProxyOnlyResourceListResultCreateRequest + // callback for handling response errors + errorer dataCollectionRuleAssociationProxyOnlyResourceListResultHandleError + // callback for handling the HTTP response + responder dataCollectionRuleAssociationProxyOnlyResourceListResultHandleResponse + // callback for advancing to the next page + advancer dataCollectionRuleAssociationProxyOnlyResourceListResultAdvancePage + // contains the current response + current DataCollectionRuleAssociationProxyOnlyResourceListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *dataCollectionRuleAssociationProxyOnlyResourceListResultPager) Err() error { + return p.err +} + +func (p *dataCollectionRuleAssociationProxyOnlyResourceListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DataCollectionRuleAssociationProxyOnlyResourceListResult.NextLink == nil || len(*p.current.DataCollectionRuleAssociationProxyOnlyResourceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *dataCollectionRuleAssociationProxyOnlyResourceListResultPager) PageResponse() DataCollectionRuleAssociationProxyOnlyResourceListResultResponse { + return p.current +} + +// DataCollectionRuleResourceListResultPager provides iteration over DataCollectionRuleResourceListResult pages. +type DataCollectionRuleResourceListResultPager interface { + azcore.Pager + + // PageResponse returns the current DataCollectionRuleResourceListResultResponse. + PageResponse() DataCollectionRuleResourceListResultResponse +} + +type dataCollectionRuleResourceListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type dataCollectionRuleResourceListResultHandleError func(*azcore.Response) error + +type dataCollectionRuleResourceListResultHandleResponse func(*azcore.Response) (DataCollectionRuleResourceListResultResponse, error) + +type dataCollectionRuleResourceListResultAdvancePage func(context.Context, DataCollectionRuleResourceListResultResponse) (*azcore.Request, error) + +type dataCollectionRuleResourceListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester dataCollectionRuleResourceListResultCreateRequest + // callback for handling response errors + errorer dataCollectionRuleResourceListResultHandleError + // callback for handling the HTTP response + responder dataCollectionRuleResourceListResultHandleResponse + // callback for advancing to the next page + advancer dataCollectionRuleResourceListResultAdvancePage + // contains the current response + current DataCollectionRuleResourceListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *dataCollectionRuleResourceListResultPager) Err() error { + return p.err +} + +func (p *dataCollectionRuleResourceListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DataCollectionRuleResourceListResult.NextLink == nil || len(*p.current.DataCollectionRuleResourceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *dataCollectionRuleResourceListResultPager) PageResponse() DataCollectionRuleResourceListResultResponse { + return p.current +} + +// EventDataCollectionPager provides iteration over EventDataCollection pages. +type EventDataCollectionPager interface { + azcore.Pager + + // PageResponse returns the current EventDataCollectionResponse. + PageResponse() EventDataCollectionResponse +} + +type eventDataCollectionCreateRequest func(context.Context) (*azcore.Request, error) + +type eventDataCollectionHandleError func(*azcore.Response) error + +type eventDataCollectionHandleResponse func(*azcore.Response) (EventDataCollectionResponse, error) + +type eventDataCollectionAdvancePage func(context.Context, EventDataCollectionResponse) (*azcore.Request, error) + +type eventDataCollectionPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester eventDataCollectionCreateRequest + // callback for handling response errors + errorer eventDataCollectionHandleError + // callback for handling the HTTP response + responder eventDataCollectionHandleResponse + // callback for advancing to the next page + advancer eventDataCollectionAdvancePage + // contains the current response + current EventDataCollectionResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *eventDataCollectionPager) Err() error { + return p.err +} + +func (p *eventDataCollectionPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.EventDataCollection.NextLink == nil || len(*p.current.EventDataCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *eventDataCollectionPager) PageResponse() EventDataCollectionResponse { + return p.current +} + +// PrivateEndpointConnectionListResultPager provides iteration over PrivateEndpointConnectionListResult pages. +type PrivateEndpointConnectionListResultPager interface { + azcore.Pager + + // PageResponse returns the current PrivateEndpointConnectionListResultResponse. + PageResponse() PrivateEndpointConnectionListResultResponse +} + +type privateEndpointConnectionListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type privateEndpointConnectionListResultHandleError func(*azcore.Response) error + +type privateEndpointConnectionListResultHandleResponse func(*azcore.Response) (PrivateEndpointConnectionListResultResponse, error) + +type privateEndpointConnectionListResultAdvancePage func(context.Context, PrivateEndpointConnectionListResultResponse) (*azcore.Request, error) + +type privateEndpointConnectionListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester privateEndpointConnectionListResultCreateRequest + // callback for handling response errors + errorer privateEndpointConnectionListResultHandleError + // callback for handling the HTTP response + responder privateEndpointConnectionListResultHandleResponse + // callback for advancing to the next page + advancer privateEndpointConnectionListResultAdvancePage + // contains the current response + current PrivateEndpointConnectionListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *privateEndpointConnectionListResultPager) Err() error { + return p.err +} + +func (p *privateEndpointConnectionListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PrivateEndpointConnectionListResult.NextLink == nil || len(*p.current.PrivateEndpointConnectionListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *privateEndpointConnectionListResultPager) PageResponse() PrivateEndpointConnectionListResultResponse { + return p.current +} + +// PrivateLinkResourceListResultPager provides iteration over PrivateLinkResourceListResult pages. +type PrivateLinkResourceListResultPager interface { + azcore.Pager + + // PageResponse returns the current PrivateLinkResourceListResultResponse. + PageResponse() PrivateLinkResourceListResultResponse +} + +type privateLinkResourceListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type privateLinkResourceListResultHandleError func(*azcore.Response) error + +type privateLinkResourceListResultHandleResponse func(*azcore.Response) (PrivateLinkResourceListResultResponse, error) + +type privateLinkResourceListResultAdvancePage func(context.Context, PrivateLinkResourceListResultResponse) (*azcore.Request, error) + +type privateLinkResourceListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester privateLinkResourceListResultCreateRequest + // callback for handling response errors + errorer privateLinkResourceListResultHandleError + // callback for handling the HTTP response + responder privateLinkResourceListResultHandleResponse + // callback for advancing to the next page + advancer privateLinkResourceListResultAdvancePage + // contains the current response + current PrivateLinkResourceListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *privateLinkResourceListResultPager) Err() error { + return p.err +} + +func (p *privateLinkResourceListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PrivateLinkResourceListResult.NextLink == nil || len(*p.current.PrivateLinkResourceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *privateLinkResourceListResultPager) PageResponse() PrivateLinkResourceListResultResponse { + return p.current +} + +// ScopedResourceListResultPager provides iteration over ScopedResourceListResult pages. +type ScopedResourceListResultPager interface { + azcore.Pager + + // PageResponse returns the current ScopedResourceListResultResponse. + PageResponse() ScopedResourceListResultResponse +} + +type scopedResourceListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type scopedResourceListResultHandleError func(*azcore.Response) error + +type scopedResourceListResultHandleResponse func(*azcore.Response) (ScopedResourceListResultResponse, error) + +type scopedResourceListResultAdvancePage func(context.Context, ScopedResourceListResultResponse) (*azcore.Request, error) + +type scopedResourceListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester scopedResourceListResultCreateRequest + // callback for handling response errors + errorer scopedResourceListResultHandleError + // callback for handling the HTTP response + responder scopedResourceListResultHandleResponse + // callback for advancing to the next page + advancer scopedResourceListResultAdvancePage + // contains the current response + current ScopedResourceListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *scopedResourceListResultPager) Err() error { + return p.err +} + +func (p *scopedResourceListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ScopedResourceListResult.NextLink == nil || len(*p.current.ScopedResourceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *scopedResourceListResultPager) PageResponse() ScopedResourceListResultResponse { + return p.current +} diff --git a/sdk/monitor/armmonitor/zz_generated_pollers.go b/sdk/monitor/armmonitor/zz_generated_pollers.go new file mode 100644 index 000000000000..f8f37a4d78b7 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_pollers.go @@ -0,0 +1,139 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "time" +) + +// HTTPPoller provides polling facilities until the operation reaches a terminal state. +type HTTPPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final *http.Response will be returned. + FinalResponse(ctx context.Context) (*http.Response, error) +} + +type httpPoller struct { + pt *armcore.LROPoller +} + +func (p *httpPoller) Done() bool { + return p.pt.Done() +} + +func (p *httpPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *httpPoller) FinalResponse(ctx context.Context) (*http.Response, error) { + return p.pt.FinalResponse(ctx, nil) +} + +func (p *httpPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *httpPoller) pollUntilDone(ctx context.Context, freq time.Duration) (*http.Response, error) { + return p.pt.PollUntilDone(ctx, freq, nil) +} + +// PrivateEndpointConnectionPoller provides polling facilities until the operation reaches a terminal state. +type PrivateEndpointConnectionPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final PrivateEndpointConnectionResponse will be returned. + FinalResponse(ctx context.Context) (PrivateEndpointConnectionResponse, error) +} + +type privateEndpointConnectionPoller struct { + pt *armcore.LROPoller +} + +func (p *privateEndpointConnectionPoller) Done() bool { + return p.pt.Done() +} + +func (p *privateEndpointConnectionPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *privateEndpointConnectionPoller) FinalResponse(ctx context.Context) (PrivateEndpointConnectionResponse, error) { + respType := PrivateEndpointConnectionResponse{PrivateEndpointConnection: &PrivateEndpointConnection{}} + resp, err := p.pt.FinalResponse(ctx, respType.PrivateEndpointConnection) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *privateEndpointConnectionPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *privateEndpointConnectionPoller) pollUntilDone(ctx context.Context, freq time.Duration) (PrivateEndpointConnectionResponse, error) { + respType := PrivateEndpointConnectionResponse{PrivateEndpointConnection: &PrivateEndpointConnection{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.PrivateEndpointConnection) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ScopedResourcePoller provides polling facilities until the operation reaches a terminal state. +type ScopedResourcePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ScopedResourceResponse will be returned. + FinalResponse(ctx context.Context) (ScopedResourceResponse, error) +} + +type scopedResourcePoller struct { + pt *armcore.LROPoller +} + +func (p *scopedResourcePoller) Done() bool { + return p.pt.Done() +} + +func (p *scopedResourcePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *scopedResourcePoller) FinalResponse(ctx context.Context) (ScopedResourceResponse, error) { + respType := ScopedResourceResponse{ScopedResource: &ScopedResource{}} + resp, err := p.pt.FinalResponse(ctx, respType.ScopedResource) + if err != nil { + return ScopedResourceResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *scopedResourcePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *scopedResourcePoller) pollUntilDone(ctx context.Context, freq time.Duration) (ScopedResourceResponse, error) { + respType := ScopedResourceResponse{ScopedResource: &ScopedResource{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.ScopedResource) + if err != nil { + return ScopedResourceResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} diff --git a/sdk/monitor/armmonitor/zz_generated_polymorphic_helpers.go b/sdk/monitor/armmonitor/zz_generated_polymorphic_helpers.go new file mode 100644 index 000000000000..4d43e5c8ff8a --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_polymorphic_helpers.go @@ -0,0 +1,248 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import "encoding/json" + +func unmarshalActionClassification(rawMsg json.RawMessage) (ActionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b ActionClassification + switch m["odata.type"] { + case "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction": + b = &AlertingAction{} + case "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction": + b = &LogToMetricAction{} + default: + b = &Action{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalActionClassificationArray(rawMsg json.RawMessage) ([]ActionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]ActionClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalActionClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalMetricAlertCriteriaClassification(rawMsg json.RawMessage) (MetricAlertCriteriaClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b MetricAlertCriteriaClassification + switch m["odata.type"] { + case string(OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria): + b = &MetricAlertMultipleResourceMultipleMetricCriteria{} + case string(OdatatypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria): + b = &MetricAlertSingleResourceMultipleMetricCriteria{} + case string(OdatatypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria): + b = &WebtestLocationAvailabilityCriteria{} + default: + b = &MetricAlertCriteria{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalMetricAlertCriteriaClassificationArray(rawMsg json.RawMessage) ([]MetricAlertCriteriaClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]MetricAlertCriteriaClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalMetricAlertCriteriaClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalMultiMetricCriteriaClassification(rawMsg json.RawMessage) (MultiMetricCriteriaClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b MultiMetricCriteriaClassification + switch m["criterionType"] { + case string(CriterionTypeDynamicThresholdCriterion): + b = &DynamicMetricCriteria{} + case string(CriterionTypeStaticThresholdCriterion): + b = &MetricCriteria{} + default: + b = &MultiMetricCriteria{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalMultiMetricCriteriaClassificationArray(rawMsg json.RawMessage) ([]MultiMetricCriteriaClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]MultiMetricCriteriaClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalMultiMetricCriteriaClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalRuleActionClassification(rawMsg json.RawMessage) (RuleActionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b RuleActionClassification + switch m["odata.type"] { + case "Microsoft.Azure.Management.Insights.Models.RuleEmailAction": + b = &RuleEmailAction{} + case "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction": + b = &RuleWebhookAction{} + default: + b = &RuleAction{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalRuleActionClassificationArray(rawMsg json.RawMessage) ([]RuleActionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]RuleActionClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalRuleActionClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalRuleConditionClassification(rawMsg json.RawMessage) (RuleConditionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b RuleConditionClassification + switch m["odata.type"] { + case "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition": + b = &LocationThresholdRuleCondition{} + case "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition": + b = &ManagementEventRuleCondition{} + case "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition": + b = &ThresholdRuleCondition{} + default: + b = &RuleCondition{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalRuleConditionClassificationArray(rawMsg json.RawMessage) ([]RuleConditionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]RuleConditionClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalRuleConditionClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalRuleDataSourceClassification(rawMsg json.RawMessage) (RuleDataSourceClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b RuleDataSourceClassification + switch m["odata.type"] { + case "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource": + b = &RuleManagementEventDataSource{} + case "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource": + b = &RuleMetricDataSource{} + default: + b = &RuleDataSource{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalRuleDataSourceClassificationArray(rawMsg json.RawMessage) ([]RuleDataSourceClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]RuleDataSourceClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalRuleDataSourceClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} diff --git a/sdk/monitor/armmonitor/zz_generated_privateendpointconnections_client.go b/sdk/monitor/armmonitor/zz_generated_privateendpointconnections_client.go new file mode 100644 index 000000000000..586988eb91ae --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_privateendpointconnections_client.go @@ -0,0 +1,380 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. +// Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. +type PrivateEndpointConnectionsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. +func NewPrivateEndpointConnectionsClient(con *armcore.Connection, subscriptionID string) *PrivateEndpointConnectionsClient { + return &PrivateEndpointConnectionsClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Approve or reject a private endpoint connection with a given name. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (PrivateEndpointConnectionPollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, scopeName, privateEndpointConnectionName, parameters, options) + if err != nil { + return PrivateEndpointConnectionPollerResponse{}, err + } + result := PrivateEndpointConnectionPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PrivateEndpointConnectionsClient.CreateOrUpdate", "", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return PrivateEndpointConnectionPollerResponse{}, err + } + poller := &privateEndpointConnectionPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PrivateEndpointConnectionResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new PrivateEndpointConnectionPoller from the specified resume token. +// token - The value must come from a previous call to PrivateEndpointConnectionPoller.ResumeToken(). +func (client *PrivateEndpointConnectionsClient) ResumeCreateOrUpdate(ctx context.Context, token string) (PrivateEndpointConnectionPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PrivateEndpointConnectionsClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return PrivateEndpointConnectionPollerResponse{}, err + } + poller := &privateEndpointConnectionPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return PrivateEndpointConnectionPollerResponse{}, err + } + result := PrivateEndpointConnectionPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PrivateEndpointConnectionResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Approve or reject a private endpoint connection with a given name. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, scopeName, privateEndpointConnectionName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PrivateEndpointConnectionsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes a private endpoint connection with a given name. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, scopeName, privateEndpointConnectionName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PrivateEndpointConnectionsClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *PrivateEndpointConnectionsClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PrivateEndpointConnectionsClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a private endpoint connection with a given name. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, scopeName, privateEndpointConnectionName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PrivateEndpointConnectionsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets a private endpoint connection. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (PrivateEndpointConnectionResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, scopeName, privateEndpointConnectionName, options) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PrivateEndpointConnectionResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *azcore.Response) (PrivateEndpointConnectionResponse, error) { + var val *PrivateEndpointConnection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return PrivateEndpointConnectionResponse{}, err + } + return PrivateEndpointConnectionResponse{RawResponse: resp.Response, PrivateEndpointConnection: val}, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateEndpointConnectionsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListByPrivateLinkScope - Gets all private endpoint connections on a private link scope. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) ListByPrivateLinkScope(resourceGroupName string, scopeName string, options *PrivateEndpointConnectionsListByPrivateLinkScopeOptions) PrivateEndpointConnectionListResultPager { + return &privateEndpointConnectionListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByPrivateLinkScopeCreateRequest(ctx, resourceGroupName, scopeName, options) + }, + responder: client.listByPrivateLinkScopeHandleResponse, + errorer: client.listByPrivateLinkScopeHandleError, + advancer: func(ctx context.Context, resp PrivateEndpointConnectionListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.PrivateEndpointConnectionListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listByPrivateLinkScopeCreateRequest creates the ListByPrivateLinkScope request. +func (client *PrivateEndpointConnectionsClient) listByPrivateLinkScopeCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateEndpointConnectionsListByPrivateLinkScopeOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByPrivateLinkScopeHandleResponse handles the ListByPrivateLinkScope response. +func (client *PrivateEndpointConnectionsClient) listByPrivateLinkScopeHandleResponse(resp *azcore.Response) (PrivateEndpointConnectionListResultResponse, error) { + var val *PrivateEndpointConnectionListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return PrivateEndpointConnectionListResultResponse{}, err + } + return PrivateEndpointConnectionListResultResponse{RawResponse: resp.Response, PrivateEndpointConnectionListResult: val}, nil +} + +// listByPrivateLinkScopeHandleError handles the ListByPrivateLinkScope error response. +func (client *PrivateEndpointConnectionsClient) listByPrivateLinkScopeHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_privatelinkresources_client.go b/sdk/monitor/armmonitor/zz_generated_privatelinkresources_client.go new file mode 100644 index 000000000000..f292176c1f68 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_privatelinkresources_client.go @@ -0,0 +1,164 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. +// Don't use this type directly, use NewPrivateLinkResourcesClient() instead. +type PrivateLinkResourcesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. +func NewPrivateLinkResourcesClient(con *armcore.Connection, subscriptionID string) *PrivateLinkResourcesClient { + return &PrivateLinkResourcesClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. +// If the operation fails it returns a generic error. +func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, scopeName string, groupName string, options *PrivateLinkResourcesGetOptions) (PrivateLinkResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, scopeName, groupName, options) + if err != nil { + return PrivateLinkResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PrivateLinkResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PrivateLinkResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, groupName string, options *PrivateLinkResourcesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + if groupName == "" { + return nil, errors.New("parameter groupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupName}", url.PathEscape(groupName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateLinkResourcesClient) getHandleResponse(resp *azcore.Response) (PrivateLinkResourceResponse, error) { + var val *PrivateLinkResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return PrivateLinkResourceResponse{}, err + } + return PrivateLinkResourceResponse{RawResponse: resp.Response, PrivateLinkResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateLinkResourcesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListByPrivateLinkScope - Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. +// If the operation fails it returns a generic error. +func (client *PrivateLinkResourcesClient) ListByPrivateLinkScope(resourceGroupName string, scopeName string, options *PrivateLinkResourcesListByPrivateLinkScopeOptions) PrivateLinkResourceListResultPager { + return &privateLinkResourceListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByPrivateLinkScopeCreateRequest(ctx, resourceGroupName, scopeName, options) + }, + responder: client.listByPrivateLinkScopeHandleResponse, + errorer: client.listByPrivateLinkScopeHandleError, + advancer: func(ctx context.Context, resp PrivateLinkResourceListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.PrivateLinkResourceListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listByPrivateLinkScopeCreateRequest creates the ListByPrivateLinkScope request. +func (client *PrivateLinkResourcesClient) listByPrivateLinkScopeCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateLinkResourcesListByPrivateLinkScopeOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByPrivateLinkScopeHandleResponse handles the ListByPrivateLinkScope response. +func (client *PrivateLinkResourcesClient) listByPrivateLinkScopeHandleResponse(resp *azcore.Response) (PrivateLinkResourceListResultResponse, error) { + var val *PrivateLinkResourceListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return PrivateLinkResourceListResultResponse{}, err + } + return PrivateLinkResourceListResultResponse{RawResponse: resp.Response, PrivateLinkResourceListResult: val}, nil +} + +// listByPrivateLinkScopeHandleError handles the ListByPrivateLinkScope error response. +func (client *PrivateLinkResourcesClient) listByPrivateLinkScopeHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_privatelinkscopedresources_client.go b/sdk/monitor/armmonitor/zz_generated_privatelinkscopedresources_client.go new file mode 100644 index 000000000000..80bd7b8b6c46 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_privatelinkscopedresources_client.go @@ -0,0 +1,380 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// PrivateLinkScopedResourcesClient contains the methods for the PrivateLinkScopedResources group. +// Don't use this type directly, use NewPrivateLinkScopedResourcesClient() instead. +type PrivateLinkScopedResourcesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPrivateLinkScopedResourcesClient creates a new instance of PrivateLinkScopedResourcesClient with the specified values. +func NewPrivateLinkScopedResourcesClient(con *armcore.Connection, subscriptionID string) *PrivateLinkScopedResourcesClient { + return &PrivateLinkScopedResourcesClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Approve or reject a private endpoint connection with a given name. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopedResourcesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, name string, parameters ScopedResource, options *PrivateLinkScopedResourcesBeginCreateOrUpdateOptions) (ScopedResourcePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, scopeName, name, parameters, options) + if err != nil { + return ScopedResourcePollerResponse{}, err + } + result := ScopedResourcePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PrivateLinkScopedResourcesClient.CreateOrUpdate", "", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return ScopedResourcePollerResponse{}, err + } + poller := &scopedResourcePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ScopedResourceResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new ScopedResourcePoller from the specified resume token. +// token - The value must come from a previous call to ScopedResourcePoller.ResumeToken(). +func (client *PrivateLinkScopedResourcesClient) ResumeCreateOrUpdate(ctx context.Context, token string) (ScopedResourcePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PrivateLinkScopedResourcesClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return ScopedResourcePollerResponse{}, err + } + poller := &scopedResourcePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ScopedResourcePollerResponse{}, err + } + result := ScopedResourcePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ScopedResourceResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Approve or reject a private endpoint connection with a given name. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopedResourcesClient) createOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, name string, parameters ScopedResource, options *PrivateLinkScopedResourcesBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, scopeName, name, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PrivateLinkScopedResourcesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, name string, parameters ScopedResource, options *PrivateLinkScopedResourcesBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PrivateLinkScopedResourcesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes a private endpoint connection with a given name. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopedResourcesClient) BeginDelete(ctx context.Context, resourceGroupName string, scopeName string, name string, options *PrivateLinkScopedResourcesBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, scopeName, name, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PrivateLinkScopedResourcesClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *PrivateLinkScopedResourcesClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PrivateLinkScopedResourcesClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a private endpoint connection with a given name. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopedResourcesClient) deleteOperation(ctx context.Context, resourceGroupName string, scopeName string, name string, options *PrivateLinkScopedResourcesBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, scopeName, name, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateLinkScopedResourcesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, name string, options *PrivateLinkScopedResourcesBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PrivateLinkScopedResourcesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets a scoped resource in a private link scope. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopedResourcesClient) Get(ctx context.Context, resourceGroupName string, scopeName string, name string, options *PrivateLinkScopedResourcesGetOptions) (ScopedResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, scopeName, name, options) + if err != nil { + return ScopedResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ScopedResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ScopedResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateLinkScopedResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, name string, options *PrivateLinkScopedResourcesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateLinkScopedResourcesClient) getHandleResponse(resp *azcore.Response) (ScopedResourceResponse, error) { + var val *ScopedResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ScopedResourceResponse{}, err + } + return ScopedResourceResponse{RawResponse: resp.Response, ScopedResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateLinkScopedResourcesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListByPrivateLinkScope - Gets all private endpoint connections on a private link scope. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopedResourcesClient) ListByPrivateLinkScope(resourceGroupName string, scopeName string, options *PrivateLinkScopedResourcesListByPrivateLinkScopeOptions) ScopedResourceListResultPager { + return &scopedResourceListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByPrivateLinkScopeCreateRequest(ctx, resourceGroupName, scopeName, options) + }, + responder: client.listByPrivateLinkScopeHandleResponse, + errorer: client.listByPrivateLinkScopeHandleError, + advancer: func(ctx context.Context, resp ScopedResourceListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ScopedResourceListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listByPrivateLinkScopeCreateRequest creates the ListByPrivateLinkScope request. +func (client *PrivateLinkScopedResourcesClient) listByPrivateLinkScopeCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateLinkScopedResourcesListByPrivateLinkScopeOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByPrivateLinkScopeHandleResponse handles the ListByPrivateLinkScope response. +func (client *PrivateLinkScopedResourcesClient) listByPrivateLinkScopeHandleResponse(resp *azcore.Response) (ScopedResourceListResultResponse, error) { + var val *ScopedResourceListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ScopedResourceListResultResponse{}, err + } + return ScopedResourceListResultResponse{RawResponse: resp.Response, ScopedResourceListResult: val}, nil +} + +// listByPrivateLinkScopeHandleError handles the ListByPrivateLinkScope error response. +func (client *PrivateLinkScopedResourcesClient) listByPrivateLinkScopeHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_privatelinkscopeoperationstatus_client.go b/sdk/monitor/armmonitor/zz_generated_privatelinkscopeoperationstatus_client.go new file mode 100644 index 000000000000..bc317e3724ae --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_privatelinkscopeoperationstatus_client.go @@ -0,0 +1,95 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// PrivateLinkScopeOperationStatusClient contains the methods for the PrivateLinkScopeOperationStatus group. +// Don't use this type directly, use NewPrivateLinkScopeOperationStatusClient() instead. +type PrivateLinkScopeOperationStatusClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPrivateLinkScopeOperationStatusClient creates a new instance of PrivateLinkScopeOperationStatusClient with the specified values. +func NewPrivateLinkScopeOperationStatusClient(con *armcore.Connection, subscriptionID string) *PrivateLinkScopeOperationStatusClient { + return &PrivateLinkScopeOperationStatusClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Get the status of an azure asynchronous operation associated with a private link scope operation. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopeOperationStatusClient) Get(ctx context.Context, asyncOperationID string, resourceGroupName string, options *PrivateLinkScopeOperationStatusGetOptions) (OperationStatusResponse, error) { + req, err := client.getCreateRequest(ctx, asyncOperationID, resourceGroupName, options) + if err != nil { + return OperationStatusResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return OperationStatusResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return OperationStatusResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateLinkScopeOperationStatusClient) getCreateRequest(ctx context.Context, asyncOperationID string, resourceGroupName string, options *PrivateLinkScopeOperationStatusGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}" + if asyncOperationID == "" { + return nil, errors.New("parameter asyncOperationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{asyncOperationId}", url.PathEscape(asyncOperationID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateLinkScopeOperationStatusClient) getHandleResponse(resp *azcore.Response) (OperationStatusResponse, error) { + var val *OperationStatus + if err := resp.UnmarshalAsJSON(&val); err != nil { + return OperationStatusResponse{}, err + } + return OperationStatusResponse{RawResponse: resp.Response, OperationStatus: val}, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateLinkScopeOperationStatusClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_privatelinkscopes_client.go b/sdk/monitor/armmonitor/zz_generated_privatelinkscopes_client.go new file mode 100644 index 000000000000..b68dcbe38ba7 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_privatelinkscopes_client.go @@ -0,0 +1,448 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// PrivateLinkScopesClient contains the methods for the PrivateLinkScopes group. +// Don't use this type directly, use NewPrivateLinkScopesClient() instead. +type PrivateLinkScopesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPrivateLinkScopesClient creates a new instance of PrivateLinkScopesClient with the specified values. +func NewPrivateLinkScopesClient(con *armcore.Connection, subscriptionID string) *PrivateLinkScopesClient { + return &PrivateLinkScopesClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different value for InstrumentationKey nor AppId in +// the Put operation. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, azureMonitorPrivateLinkScopePayload AzureMonitorPrivateLinkScope, options *PrivateLinkScopesCreateOrUpdateOptions) (AzureMonitorPrivateLinkScopeResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, scopeName, azureMonitorPrivateLinkScopePayload, options) + if err != nil { + return AzureMonitorPrivateLinkScopeResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AzureMonitorPrivateLinkScopeResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return AzureMonitorPrivateLinkScopeResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PrivateLinkScopesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, azureMonitorPrivateLinkScopePayload AzureMonitorPrivateLinkScope, options *PrivateLinkScopesCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(azureMonitorPrivateLinkScopePayload) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PrivateLinkScopesClient) createOrUpdateHandleResponse(resp *azcore.Response) (AzureMonitorPrivateLinkScopeResponse, error) { + var val *AzureMonitorPrivateLinkScope + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AzureMonitorPrivateLinkScopeResponse{}, err + } + return AzureMonitorPrivateLinkScopeResponse{RawResponse: resp.Response, AzureMonitorPrivateLinkScope: val}, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PrivateLinkScopesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes a Azure Monitor PrivateLinkScope. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopesClient) BeginDelete(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateLinkScopesBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, scopeName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PrivateLinkScopesClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *PrivateLinkScopesClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PrivateLinkScopesClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a Azure Monitor PrivateLinkScope. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopesClient) deleteOperation(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateLinkScopesBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, scopeName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateLinkScopesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateLinkScopesBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PrivateLinkScopesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Returns a Azure Monitor PrivateLinkScope. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopesClient) Get(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateLinkScopesGetOptions) (AzureMonitorPrivateLinkScopeResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, scopeName, options) + if err != nil { + return AzureMonitorPrivateLinkScopeResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AzureMonitorPrivateLinkScopeResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AzureMonitorPrivateLinkScopeResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateLinkScopesClient) getCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, options *PrivateLinkScopesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateLinkScopesClient) getHandleResponse(resp *azcore.Response) (AzureMonitorPrivateLinkScopeResponse, error) { + var val *AzureMonitorPrivateLinkScope + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AzureMonitorPrivateLinkScopeResponse{}, err + } + return AzureMonitorPrivateLinkScopeResponse{RawResponse: resp.Response, AzureMonitorPrivateLinkScope: val}, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateLinkScopesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// List - Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopesClient) List(options *PrivateLinkScopesListOptions) AzureMonitorPrivateLinkScopeListResultPager { + return &azureMonitorPrivateLinkScopeListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp AzureMonitorPrivateLinkScopeListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.AzureMonitorPrivateLinkScopeListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *PrivateLinkScopesClient) listCreateRequest(ctx context.Context, options *PrivateLinkScopesListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateLinkScopesClient) listHandleResponse(resp *azcore.Response) (AzureMonitorPrivateLinkScopeListResultResponse, error) { + var val *AzureMonitorPrivateLinkScopeListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AzureMonitorPrivateLinkScopeListResultResponse{}, err + } + return AzureMonitorPrivateLinkScopeListResultResponse{RawResponse: resp.Response, AzureMonitorPrivateLinkScopeListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *PrivateLinkScopesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListByResourceGroup - Gets a list of Azure Monitor PrivateLinkScopes within a resource group. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopesClient) ListByResourceGroup(resourceGroupName string, options *PrivateLinkScopesListByResourceGroupOptions) AzureMonitorPrivateLinkScopeListResultPager { + return &azureMonitorPrivateLinkScopeListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + responder: client.listByResourceGroupHandleResponse, + errorer: client.listByResourceGroupHandleError, + advancer: func(ctx context.Context, resp AzureMonitorPrivateLinkScopeListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.AzureMonitorPrivateLinkScopeListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *PrivateLinkScopesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *PrivateLinkScopesListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *PrivateLinkScopesClient) listByResourceGroupHandleResponse(resp *azcore.Response) (AzureMonitorPrivateLinkScopeListResultResponse, error) { + var val *AzureMonitorPrivateLinkScopeListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AzureMonitorPrivateLinkScopeListResultResponse{}, err + } + return AzureMonitorPrivateLinkScopeListResultResponse{RawResponse: resp.Response, AzureMonitorPrivateLinkScopeListResult: val}, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *PrivateLinkScopesClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// UpdateTags - Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate method. +// If the operation fails it returns a generic error. +func (client *PrivateLinkScopesClient) UpdateTags(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags TagsResource, options *PrivateLinkScopesUpdateTagsOptions) (AzureMonitorPrivateLinkScopeResponse, error) { + req, err := client.updateTagsCreateRequest(ctx, resourceGroupName, scopeName, privateLinkScopeTags, options) + if err != nil { + return AzureMonitorPrivateLinkScopeResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AzureMonitorPrivateLinkScopeResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AzureMonitorPrivateLinkScopeResponse{}, client.updateTagsHandleError(resp) + } + return client.updateTagsHandleResponse(resp) +} + +// updateTagsCreateRequest creates the UpdateTags request. +func (client *PrivateLinkScopesClient) updateTagsCreateRequest(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags TagsResource, options *PrivateLinkScopesUpdateTagsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if scopeName == "" { + return nil, errors.New("parameter scopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeName}", url.PathEscape(scopeName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-10-17-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(privateLinkScopeTags) +} + +// updateTagsHandleResponse handles the UpdateTags response. +func (client *PrivateLinkScopesClient) updateTagsHandleResponse(resp *azcore.Response) (AzureMonitorPrivateLinkScopeResponse, error) { + var val *AzureMonitorPrivateLinkScope + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AzureMonitorPrivateLinkScopeResponse{}, err + } + return AzureMonitorPrivateLinkScopeResponse{RawResponse: resp.Response, AzureMonitorPrivateLinkScope: val}, nil +} + +// updateTagsHandleError handles the UpdateTags error response. +func (client *PrivateLinkScopesClient) updateTagsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_response_types.go b/sdk/monitor/armmonitor/zz_generated_response_types.go new file mode 100644 index 000000000000..167420bfed4d --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_response_types.go @@ -0,0 +1,449 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "net/http" + "time" +) + +// ActionGroupListResponse is the response envelope for operations that return a ActionGroupList type. +type ActionGroupListResponse struct { + // A list of action groups. + ActionGroupList *ActionGroupList + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ActionGroupResourceResponse is the response envelope for operations that return a ActionGroupResource type. +type ActionGroupResourceResponse struct { + // An action group resource. + ActionGroupResource *ActionGroupResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ActivityLogAlertListResponse is the response envelope for operations that return a ActivityLogAlertList type. +type ActivityLogAlertListResponse struct { + // A list of activity log alerts. + ActivityLogAlertList *ActivityLogAlertList + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ActivityLogAlertResourceResponse is the response envelope for operations that return a ActivityLogAlertResource type. +type ActivityLogAlertResourceResponse struct { + // An activity log alert resource. + ActivityLogAlertResource *ActivityLogAlertResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AlertRuleResourceCollectionResponse is the response envelope for operations that return a AlertRuleResourceCollection type. +type AlertRuleResourceCollectionResponse struct { + // Represents a collection of alert rule resources. + AlertRuleResourceCollection *AlertRuleResourceCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AlertRuleResourceResponse is the response envelope for operations that return a AlertRuleResource type. +type AlertRuleResourceResponse struct { + // The alert rule resource. + AlertRuleResource *AlertRuleResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AutoscaleSettingResourceCollectionResponse is the response envelope for operations that return a AutoscaleSettingResourceCollection type. +type AutoscaleSettingResourceCollectionResponse struct { + // Represents a collection of autoscale setting resources. + AutoscaleSettingResourceCollection *AutoscaleSettingResourceCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AutoscaleSettingResourceResponse is the response envelope for operations that return a AutoscaleSettingResource type. +type AutoscaleSettingResourceResponse struct { + // The autoscale setting resource. + AutoscaleSettingResource *AutoscaleSettingResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AzureMonitorPrivateLinkScopeListResultResponse is the response envelope for operations that return a AzureMonitorPrivateLinkScopeListResult type. +type AzureMonitorPrivateLinkScopeListResultResponse struct { + // Describes the list of Azure Monitor PrivateLinkScope resources. + AzureMonitorPrivateLinkScopeListResult *AzureMonitorPrivateLinkScopeListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AzureMonitorPrivateLinkScopeResponse is the response envelope for operations that return a AzureMonitorPrivateLinkScope type. +type AzureMonitorPrivateLinkScopeResponse struct { + // An Azure Monitor PrivateLinkScope definition. + AzureMonitorPrivateLinkScope *AzureMonitorPrivateLinkScope + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataCollectionEndpointResourceListResultResponse is the response envelope for operations that return a DataCollectionEndpointResourceListResult type. +type DataCollectionEndpointResourceListResultResponse struct { + // A pageable list of resources. + DataCollectionEndpointResourceListResult *DataCollectionEndpointResourceListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataCollectionEndpointResourceResponse is the response envelope for operations that return a DataCollectionEndpointResource type. +type DataCollectionEndpointResourceResponse struct { + // Definition of ARM tracked top level resource. + DataCollectionEndpointResource *DataCollectionEndpointResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataCollectionRuleAssociationProxyOnlyResourceListResultResponse is the response envelope for operations that return a DataCollectionRuleAssociationProxyOnlyResourceListResult +// type. +type DataCollectionRuleAssociationProxyOnlyResourceListResultResponse struct { + // A pageable list of resources. + DataCollectionRuleAssociationProxyOnlyResourceListResult *DataCollectionRuleAssociationProxyOnlyResourceListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataCollectionRuleAssociationProxyOnlyResourceResponse is the response envelope for operations that return a DataCollectionRuleAssociationProxyOnlyResource +// type. +type DataCollectionRuleAssociationProxyOnlyResourceResponse struct { + // Definition of generic ARM proxy resource. + DataCollectionRuleAssociationProxyOnlyResource *DataCollectionRuleAssociationProxyOnlyResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataCollectionRuleResourceListResultResponse is the response envelope for operations that return a DataCollectionRuleResourceListResult type. +type DataCollectionRuleResourceListResultResponse struct { + // A pageable list of resources. + DataCollectionRuleResourceListResult *DataCollectionRuleResourceListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DataCollectionRuleResourceResponse is the response envelope for operations that return a DataCollectionRuleResource type. +type DataCollectionRuleResourceResponse struct { + // Definition of ARM tracked top level resource. + DataCollectionRuleResource *DataCollectionRuleResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticSettingsCategoryResourceCollectionResponse is the response envelope for operations that return a DiagnosticSettingsCategoryResourceCollection +// type. +type DiagnosticSettingsCategoryResourceCollectionResponse struct { + // Represents a collection of diagnostic setting category resources. + DiagnosticSettingsCategoryResourceCollection *DiagnosticSettingsCategoryResourceCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticSettingsCategoryResourceResponse is the response envelope for operations that return a DiagnosticSettingsCategoryResource type. +type DiagnosticSettingsCategoryResourceResponse struct { + // The diagnostic settings category resource. + DiagnosticSettingsCategoryResource *DiagnosticSettingsCategoryResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticSettingsResourceCollectionResponse is the response envelope for operations that return a DiagnosticSettingsResourceCollection type. +type DiagnosticSettingsResourceCollectionResponse struct { + // Represents a collection of alert rule resources. + DiagnosticSettingsResourceCollection *DiagnosticSettingsResourceCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticSettingsResourceResponse is the response envelope for operations that return a DiagnosticSettingsResource type. +type DiagnosticSettingsResourceResponse struct { + // The diagnostic setting resource. + DiagnosticSettingsResource *DiagnosticSettingsResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EventCategoryCollectionResponse is the response envelope for operations that return a EventCategoryCollection type. +type EventCategoryCollectionResponse struct { + // A collection of event categories. Currently possible values are: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. + EventCategoryCollection *EventCategoryCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EventDataCollectionResponse is the response envelope for operations that return a EventDataCollection type. +type EventDataCollectionResponse struct { + // Represents collection of events. + EventDataCollection *EventDataCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HTTPPollerResponse contains the asynchronous HTTP response from the call to the service endpoint. +type HTTPPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (*http.Response, error) + + // Poller contains an initialized poller. + Poller HTTPPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IncidentListResultResponse is the response envelope for operations that return a IncidentListResult type. +type IncidentListResultResponse struct { + // The List incidents operation response. + IncidentListResult *IncidentListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IncidentResponse is the response envelope for operations that return a Incident type. +type IncidentResponse struct { + // An alert incident indicates the activation status of an alert rule. + Incident *Incident + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LogProfileCollectionResponse is the response envelope for operations that return a LogProfileCollection type. +type LogProfileCollectionResponse struct { + // Represents a collection of log profiles. + LogProfileCollection *LogProfileCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LogProfileResourceResponse is the response envelope for operations that return a LogProfileResource type. +type LogProfileResourceResponse struct { + // The log profile resource. + LogProfileResource *LogProfileResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LogSearchRuleResourceCollectionResponse is the response envelope for operations that return a LogSearchRuleResourceCollection type. +type LogSearchRuleResourceCollectionResponse struct { + // Represents a collection of Log Search rule resources. + LogSearchRuleResourceCollection *LogSearchRuleResourceCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LogSearchRuleResourceResponse is the response envelope for operations that return a LogSearchRuleResource type. +type LogSearchRuleResourceResponse struct { + // The Log Search Rule resource. + LogSearchRuleResource *LogSearchRuleResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MetricAlertResourceCollectionResponse is the response envelope for operations that return a MetricAlertResourceCollection type. +type MetricAlertResourceCollectionResponse struct { + // Represents a collection of alert rule resources. + MetricAlertResourceCollection *MetricAlertResourceCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MetricAlertResourceResponse is the response envelope for operations that return a MetricAlertResource type. +type MetricAlertResourceResponse struct { + // The metric alert resource. + MetricAlertResource *MetricAlertResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MetricAlertStatusCollectionResponse is the response envelope for operations that return a MetricAlertStatusCollection type. +type MetricAlertStatusCollectionResponse struct { + // Represents a collection of alert rule resources. + MetricAlertStatusCollection *MetricAlertStatusCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MetricBaselinesResponseResponse is the response envelope for operations that return a MetricBaselinesResponse type. +type MetricBaselinesResponseResponse struct { + // A list of metric baselines. + MetricBaselinesResponse *MetricBaselinesResponse + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MetricDefinitionCollectionResponse is the response envelope for operations that return a MetricDefinitionCollection type. +type MetricDefinitionCollectionResponse struct { + // Represents collection of metric definitions. + MetricDefinitionCollection *MetricDefinitionCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// MetricNamespaceCollectionResponse is the response envelope for operations that return a MetricNamespaceCollection type. +type MetricNamespaceCollectionResponse struct { + // Represents collection of metric namespaces. + MetricNamespaceCollection *MetricNamespaceCollection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationListResultResponse is the response envelope for operations that return a OperationListResult type. +type OperationListResultResponse struct { + // 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. + OperationListResult *OperationListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationStatusResponse is the response envelope for operations that return a OperationStatus type. +type OperationStatusResponse struct { + // The status of operation. + OperationStatus *OperationStatus + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionListResultResponse is the response envelope for operations that return a PrivateEndpointConnectionListResult type. +type PrivateEndpointConnectionListResultResponse struct { + // A list of private endpoint connections. + PrivateEndpointConnectionListResult *PrivateEndpointConnectionListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionPollerResponse is the response envelope for operations that asynchronously return a PrivateEndpointConnection type. +type PrivateEndpointConnectionPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (PrivateEndpointConnectionResponse, error) + + // Poller contains an initialized poller. + Poller PrivateEndpointConnectionPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionResponse is the response envelope for operations that return a PrivateEndpointConnection type. +type PrivateEndpointConnectionResponse struct { + // A private endpoint connection + PrivateEndpointConnection *PrivateEndpointConnection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateLinkResourceListResultResponse is the response envelope for operations that return a PrivateLinkResourceListResult type. +type PrivateLinkResourceListResultResponse struct { + // A list of private link resources + PrivateLinkResourceListResult *PrivateLinkResourceListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateLinkResourceResponse is the response envelope for operations that return a PrivateLinkResource type. +type PrivateLinkResourceResponse struct { + // A private link resource + PrivateLinkResource *PrivateLinkResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ResponseResponse is the response envelope for operations that return a Response type. +type ResponseResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The response to a metrics query. + Response *Response +} + +// ScopedResourceListResultResponse is the response envelope for operations that return a ScopedResourceListResult type. +type ScopedResourceListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // A list of scoped resources in a private link scope. + ScopedResourceListResult *ScopedResourceListResult +} + +// ScopedResourcePollerResponse is the response envelope for operations that asynchronously return a ScopedResource type. +type ScopedResourcePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ScopedResourceResponse, error) + + // Poller contains an initialized poller. + Poller ScopedResourcePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScopedResourceResponse is the response envelope for operations that return a ScopedResource type. +type ScopedResourceResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // A private link scoped resource + ScopedResource *ScopedResource +} + +// VMInsightsOnboardingStatusResponse is the response envelope for operations that return a VMInsightsOnboardingStatus type. +type VMInsightsOnboardingStatusResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // VM Insights onboarding status for a resource. + VMInsightsOnboardingStatus *VMInsightsOnboardingStatus +} diff --git a/sdk/monitor/armmonitor/zz_generated_scheduledqueryrules_client.go b/sdk/monitor/armmonitor/zz_generated_scheduledqueryrules_client.go new file mode 100644 index 000000000000..f51b505750b1 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_scheduledqueryrules_client.go @@ -0,0 +1,412 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// ScheduledQueryRulesClient contains the methods for the ScheduledQueryRules group. +// Don't use this type directly, use NewScheduledQueryRulesClient() instead. +type ScheduledQueryRulesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewScheduledQueryRulesClient creates a new instance of ScheduledQueryRulesClient with the specified values. +func NewScheduledQueryRulesClient(con *armcore.Connection, subscriptionID string) *ScheduledQueryRulesClient { + return &ScheduledQueryRulesClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates an log search rule. +// If the operation fails it returns the *ErrorContract error type. +func (client *ScheduledQueryRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResource, options *ScheduledQueryRulesCreateOrUpdateOptions) (LogSearchRuleResourceResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, ruleName, parameters, options) + if err != nil { + return LogSearchRuleResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LogSearchRuleResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return LogSearchRuleResourceResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ScheduledQueryRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResource, options *ScheduledQueryRulesCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-04-16") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ScheduledQueryRulesClient) createOrUpdateHandleResponse(resp *azcore.Response) (LogSearchRuleResourceResponse, error) { + var val *LogSearchRuleResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return LogSearchRuleResourceResponse{}, err + } + return LogSearchRuleResourceResponse{RawResponse: resp.Response, LogSearchRuleResource: val}, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ScheduledQueryRulesClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorContract{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes a Log Search rule +// If the operation fails it returns the *ErrorContract error type. +func (client *ScheduledQueryRulesClient) Delete(ctx context.Context, resourceGroupName string, ruleName string, options *ScheduledQueryRulesDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, ruleName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp.Response, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ScheduledQueryRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, options *ScheduledQueryRulesDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-04-16") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ScheduledQueryRulesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorContract{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets an Log Search rule +// If the operation fails it returns the *ErrorContract error type. +func (client *ScheduledQueryRulesClient) Get(ctx context.Context, resourceGroupName string, ruleName string, options *ScheduledQueryRulesGetOptions) (LogSearchRuleResourceResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, ruleName, options) + if err != nil { + return LogSearchRuleResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LogSearchRuleResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LogSearchRuleResourceResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ScheduledQueryRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, options *ScheduledQueryRulesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-04-16") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ScheduledQueryRulesClient) getHandleResponse(resp *azcore.Response) (LogSearchRuleResourceResponse, error) { + var val *LogSearchRuleResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return LogSearchRuleResourceResponse{}, err + } + return LogSearchRuleResourceResponse{RawResponse: resp.Response, LogSearchRuleResource: val}, nil +} + +// getHandleError handles the Get error response. +func (client *ScheduledQueryRulesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorContract{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - List the Log Search rules within a resource group. +// If the operation fails it returns the *ErrorContract error type. +func (client *ScheduledQueryRulesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *ScheduledQueryRulesListByResourceGroupOptions) (LogSearchRuleResourceCollectionResponse, error) { + req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return LogSearchRuleResourceCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LogSearchRuleResourceCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LogSearchRuleResourceCollectionResponse{}, client.listByResourceGroupHandleError(resp) + } + return client.listByResourceGroupHandleResponse(resp) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ScheduledQueryRulesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ScheduledQueryRulesListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-04-16") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ScheduledQueryRulesClient) listByResourceGroupHandleResponse(resp *azcore.Response) (LogSearchRuleResourceCollectionResponse, error) { + var val *LogSearchRuleResourceCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return LogSearchRuleResourceCollectionResponse{}, err + } + return LogSearchRuleResourceCollectionResponse{RawResponse: resp.Response, LogSearchRuleResourceCollection: val}, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *ScheduledQueryRulesClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorContract{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListBySubscription - List the Log Search rules within a subscription group. +// If the operation fails it returns the *ErrorContract error type. +func (client *ScheduledQueryRulesClient) ListBySubscription(ctx context.Context, options *ScheduledQueryRulesListBySubscriptionOptions) (LogSearchRuleResourceCollectionResponse, error) { + req, err := client.listBySubscriptionCreateRequest(ctx, options) + if err != nil { + return LogSearchRuleResourceCollectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LogSearchRuleResourceCollectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LogSearchRuleResourceCollectionResponse{}, client.listBySubscriptionHandleError(resp) + } + return client.listBySubscriptionHandleResponse(resp) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ScheduledQueryRulesClient) listBySubscriptionCreateRequest(ctx context.Context, options *ScheduledQueryRulesListBySubscriptionOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-04-16") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *ScheduledQueryRulesClient) listBySubscriptionHandleResponse(resp *azcore.Response) (LogSearchRuleResourceCollectionResponse, error) { + var val *LogSearchRuleResourceCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return LogSearchRuleResourceCollectionResponse{}, err + } + return LogSearchRuleResourceCollectionResponse{RawResponse: resp.Response, LogSearchRuleResourceCollection: val}, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *ScheduledQueryRulesClient) listBySubscriptionHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorContract{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Update log search Rule. +// If the operation fails it returns the *ErrorContract error type. +func (client *ScheduledQueryRulesClient) Update(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResourcePatch, options *ScheduledQueryRulesUpdateOptions) (LogSearchRuleResourceResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, ruleName, parameters, options) + if err != nil { + return LogSearchRuleResourceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LogSearchRuleResourceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LogSearchRuleResourceResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ScheduledQueryRulesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResourcePatch, options *ScheduledQueryRulesUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-04-16") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *ScheduledQueryRulesClient) updateHandleResponse(resp *azcore.Response) (LogSearchRuleResourceResponse, error) { + var val *LogSearchRuleResource + if err := resp.UnmarshalAsJSON(&val); err != nil { + return LogSearchRuleResourceResponse{}, err + } + return LogSearchRuleResourceResponse{RawResponse: resp.Response, LogSearchRuleResource: val}, nil +} + +// updateHandleError handles the Update error response. +func (client *ScheduledQueryRulesClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorContract{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_tenantactivitylogs_client.go b/sdk/monitor/armmonitor/zz_generated_tenantactivitylogs_client.go new file mode 100644 index 000000000000..c18e6b8f9f2f --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_tenantactivitylogs_client.go @@ -0,0 +1,90 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// TenantActivityLogsClient contains the methods for the TenantActivityLogs group. +// Don't use this type directly, use NewTenantActivityLogsClient() instead. +type TenantActivityLogsClient struct { + con *armcore.Connection +} + +// NewTenantActivityLogsClient creates a new instance of TenantActivityLogsClient with the specified values. +func NewTenantActivityLogsClient(con *armcore.Connection) *TenantActivityLogsClient { + return &TenantActivityLogsClient{con: con} +} + +// 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. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantActivityLogsClient) List(options *TenantActivityLogsListOptions) EventDataCollectionPager { + return &eventDataCollectionPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp EventDataCollectionResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.EventDataCollection.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *TenantActivityLogsClient) listCreateRequest(ctx context.Context, options *TenantActivityLogsListOptions) (*azcore.Request, error) { + urlPath := "/providers/Microsoft.Insights/eventtypes/management/values" + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2015-04-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Select != nil { + reqQP.Set("$select", *options.Select) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *TenantActivityLogsClient) listHandleResponse(resp *azcore.Response) (EventDataCollectionResponse, error) { + var val *EventDataCollection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return EventDataCollectionResponse{}, err + } + return EventDataCollectionResponse{RawResponse: resp.Response, EventDataCollection: val}, nil +} + +// listHandleError handles the List error response. +func (client *TenantActivityLogsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/monitor/armmonitor/zz_generated_time_rfc3339.go b/sdk/monitor/armmonitor/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..753fb4a598ad --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_time_rfc3339.go @@ -0,0 +1,57 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} diff --git a/sdk/monitor/armmonitor/zz_generated_vminsights_client.go b/sdk/monitor/armmonitor/zz_generated_vminsights_client.go new file mode 100644 index 000000000000..ea721c3f2c37 --- /dev/null +++ b/sdk/monitor/armmonitor/zz_generated_vminsights_client.go @@ -0,0 +1,87 @@ +// +build go1.13 + +// 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. + +package armmonitor + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "strings" +) + +// VMInsightsClient contains the methods for the VMInsights group. +// Don't use this type directly, use NewVMInsightsClient() instead. +type VMInsightsClient struct { + con *armcore.Connection +} + +// NewVMInsightsClient creates a new instance of VMInsightsClient with the specified values. +func NewVMInsightsClient(con *armcore.Connection) *VMInsightsClient { + return &VMInsightsClient{con: con} +} + +// GetOnboardingStatus - Retrieves the VM Insights onboarding status for the specified resource or resource scope. +// If the operation fails it returns the *ResponseWithError error type. +func (client *VMInsightsClient) GetOnboardingStatus(ctx context.Context, resourceURI string, options *VMInsightsGetOnboardingStatusOptions) (VMInsightsOnboardingStatusResponse, error) { + req, err := client.getOnboardingStatusCreateRequest(ctx, resourceURI, options) + if err != nil { + return VMInsightsOnboardingStatusResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return VMInsightsOnboardingStatusResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return VMInsightsOnboardingStatusResponse{}, client.getOnboardingStatusHandleError(resp) + } + return client.getOnboardingStatusHandleResponse(resp) +} + +// getOnboardingStatusCreateRequest creates the GetOnboardingStatus request. +func (client *VMInsightsClient) getOnboardingStatusCreateRequest(ctx context.Context, resourceURI string, options *VMInsightsGetOnboardingStatusOptions) (*azcore.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2018-11-27-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getOnboardingStatusHandleResponse handles the GetOnboardingStatus response. +func (client *VMInsightsClient) getOnboardingStatusHandleResponse(resp *azcore.Response) (VMInsightsOnboardingStatusResponse, error) { + var val *VMInsightsOnboardingStatus + if err := resp.UnmarshalAsJSON(&val); err != nil { + return VMInsightsOnboardingStatusResponse{}, err + } + return VMInsightsOnboardingStatusResponse{RawResponse: resp.Response, VMInsightsOnboardingStatus: val}, nil +} + +// getOnboardingStatusHandleError handles the GetOnboardingStatus error response. +func (client *VMInsightsClient) getOnboardingStatusHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ResponseWithError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} From 0fa0f2f266b74d2d12d24efac8a3bc9a116e950b Mon Sep 17 00:00:00 2001 From: arcturusZhang Date: Mon, 12 Jul 2021 13:25:28 +0800 Subject: [PATCH 3/4] update readme --- sdk/monitor/armmonitor/README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sdk/monitor/armmonitor/README.md b/sdk/monitor/armmonitor/README.md index f11bb9e97fa0..d30f07737a7b 100644 --- a/sdk/monitor/armmonitor/README.md +++ b/sdk/monitor/armmonitor/README.md @@ -1,10 +1,10 @@ -# Azure Compute Module for Go +# Azure Monitor Module for Go -[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/compute/armcompute)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/compute/armcompute) +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/monitor/armmonitor)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/monitor/armmonitor) -The `armcompute` module provides operations for working with Azure compute. +The `armmonitor` module provides operations for working with Azure Monitor. -[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/compute/armcompute) +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/monitor/armmonitor) # Getting started @@ -17,15 +17,15 @@ The `armcompute` module provides operations for working with Azure compute. This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. -Install the Azure Compute module: +Install the Azure Monitor module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/compute/armcompute +go get github.com/Azure/azure-sdk-for-go/sdk/monitor/armmonitor ``` ## Authorization -When creating a client, you will need to provide a credential for authenticating with Azure Compute. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. +When creating a client, you will need to provide a credential for authenticating with Azure Monitor. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. ```go cred, err := azidentity.NewDefaultAzureCredential(nil) @@ -33,7 +33,7 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Connecting to Azure Compute +## Connecting to Azure Monitor Once you have a credential, create a connection to the desired ARM endpoint. The `armcore` module provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. @@ -45,16 +45,16 @@ For more information on ARM connections, please see the documentation for `armco ## Clients -Azure Compute modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your `armcore.Connection`. +Azure Monitor modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your `armcore.Connection`. ```go -client := armcompute.NewVirtualMachinesClient(con, "") +client := armmonitor.NewAlertRulesClient(con, "") ``` ## Provide Feedback If you encounter bugs or have suggestions, please -[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Compute` label. +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Monitor` label. # Contributing From 7ff37bd1682dab38e508eaddbe22934a259711dc Mon Sep 17 00:00:00 2001 From: arcturusZhang Date: Mon, 12 Jul 2021 13:29:57 +0800 Subject: [PATCH 4/4] regenerate and refresh the metadata --- sdk/monitor/armmonitor/_meta.json | 8 +++---- sdk/monitor/armmonitor/go.mod | 2 ++ sdk/monitor/armmonitor/go.sum | 21 +++++++++++++++++++ .../armmonitor/zz_generated_constants.go | 2 +- sdk/monitor/armmonitor/zz_generated_models.go | 6 +++++- 5 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 sdk/monitor/armmonitor/go.sum diff --git a/sdk/monitor/armmonitor/_meta.json b/sdk/monitor/armmonitor/_meta.json index 7fdf086f12ec..a148c5d11371 100644 --- a/sdk/monitor/armmonitor/_meta.json +++ b/sdk/monitor/armmonitor/_meta.json @@ -1,10 +1,10 @@ { - "commit": "f69f2e8053ac8ae352b11c33655234dea4cf4cfd", + "commit": "5e85541d5c4d00459a8e2dcb14512c964e2c1ce9", "readme": "/_/azure-rest-api-specs/specification/monitor/resource-manager/readme.md", - "tag": "package-2021-03-01", - "use": "@autorest/go@4.0.0-preview.22", + "tag": "package-2021-04", + "use": "@autorest/go@4.0.0-preview.23", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@autorest/go@4.0.0-preview.22 --go --track2 --go-sdk-folder=/_/azure-sdk-for-go --file-prefix=\"zz_generated_\" --clear-output-folder=false /_/azure-rest-api-specs/specification/monitor/resource-manager/readme.md", + "autorest_command": "autorest --use=@autorest/go@4.0.0-preview.23 --go --track2 --go-sdk-folder=/_/azure-sdk-for-go --file-prefix=\"zz_generated_\" --clear-output-folder=false /_/azure-rest-api-specs/specification/monitor/resource-manager/readme.md", "additional_properties": { "additional_options": "--go --track2 --file-prefix=\"zz_generated_\" --clear-output-folder=false" } diff --git a/sdk/monitor/armmonitor/go.mod b/sdk/monitor/armmonitor/go.mod index 9e74aed68f6d..49a91ffb15d0 100644 --- a/sdk/monitor/armmonitor/go.mod +++ b/sdk/monitor/armmonitor/go.mod @@ -3,6 +3,8 @@ module github.com/Azure/azure-sdk-for-go/sdk/monitor/armmonitor go 1.13 require ( + github.com/Azure/azure-sdk-for-go v55.6.0+incompatible github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 + golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect ) diff --git a/sdk/monitor/armmonitor/go.sum b/sdk/monitor/armmonitor/go.sum new file mode 100644 index 000000000000..94d08fc7193b --- /dev/null +++ b/sdk/monitor/armmonitor/go.sum @@ -0,0 +1,21 @@ +github.com/Azure/azure-sdk-for-go v55.6.0+incompatible h1:SDeTdsn7/wiCDVLiKR1VFDCPURKKEg59bP7ewi7kUJc= +github.com/Azure/azure-sdk-for-go v55.6.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 h1:HQQoaSGOh32mpoRkpLDjkngMwYJqkxu93FRx0epdLHE= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0/go.mod h1:BSKvHb/5cy8j4hahIInXH92X/2zGJ3TxKF6b9pw1Btg= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 h1:UC4vfOhW2l0f2QOCQpOxJS4/K6oKFy2tQZE+uWU1MEo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1 h1:vx8McI56N5oLSQu8xa+xdiE0fjQq8W8Zt49vHP8Rygw= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/sdk/monitor/armmonitor/zz_generated_constants.go b/sdk/monitor/armmonitor/zz_generated_constants.go index 476d16e2d15d..ba9878cb3832 100644 --- a/sdk/monitor/armmonitor/zz_generated_constants.go +++ b/sdk/monitor/armmonitor/zz_generated_constants.go @@ -7,7 +7,7 @@ package armmonitor -const telemetryInfo = "azsdk-go-armmonitor/" +const telemetryInfo = "azsdk-go-armmonitor/v0.1.0" // AggregationType - the aggregation type of the metric. type AggregationType string diff --git a/sdk/monitor/armmonitor/zz_generated_models.go b/sdk/monitor/armmonitor/zz_generated_models.go index 5c269297c4fc..2f76bee742d7 100644 --- a/sdk/monitor/armmonitor/zz_generated_models.go +++ b/sdk/monitor/armmonitor/zz_generated_models.go @@ -5195,7 +5195,11 @@ func (t TimeSeriesBaseline) MarshalJSON() ([]byte, error) { populate(objectMap, "data", t.Data) populate(objectMap, "dimensions", t.Dimensions) populate(objectMap, "metadataValues", t.MetadataValues) - populate(objectMap, "timestamps", t.Timestamps) + aux := make([]*timeRFC3339, len(t.Timestamps), len(t.Timestamps)) + for i := 0; i < len(t.Timestamps); i++ { + aux[i] = (*timeRFC3339)(t.Timestamps[i]) + } + populate(objectMap, "timestamps", aux) return json.Marshal(objectMap) }