From ba2af7e663b7e52ca768baf881e91b8b110cb53a Mon Sep 17 00:00:00 2001 From: beandrad Date: Fri, 18 Sep 2020 08:05:55 +0000 Subject: [PATCH] Allow to set security center pricing tier for a particular resource type At the moment, only Virtual Machines are set with the security center standard or free pricing tiers when using `azurerm_security_center_subscription_pricing`. This change adds the field `resource_type`, which allows to specify the resource type for which we want to update the pricing tier. The v1 security center pricing client only allows to get the pricing tier of the default resource type (Virtual Machines) to check whether the subscription has standard or free security center pricing tier. However, a partial standard pricing tier (where one or more resource types have standar tier enabled) allows for a security center workspace to be created. This commit changes the client to v3 and checks if any resource type in the subscription has standard pricing tier enabled, and if so, it allows the creation of a security center workspace. --- .../services/securitycenter/client/client.go | 19 +- .../security_center_subscription_pricing.go | 30 + ...curity_center_subscription_pricing_test.go | 54 + ...rm_security_center_subscription_pricing.go | 58 +- ...y_center_subscription_pricing_migration.go | 32 + .../resource_arm_security_center_workspace.go | 41 +- ...ter_subscription_pricing_migration_test.go | 38 + ...curity_center_subscription_pricing_test.go | 15 +- ...urce_arm_security_center_workspace_test.go | 9 +- .../security/securitycenter-pricing/main.tf | 8 + .../security/adaptiveapplicationcontrols.go | 376 + .../security/adaptivenetworkhardenings.go | 364 + .../v3.0/security/advancedthreatprotection.go | 192 + .../security/mgmt/v3.0/security/alerts.go | 1098 + .../v3.0/security/alertssuppressionrules.go | 412 + .../mgmt/v3.0/security/allowedconnections.go | 367 + .../mgmt/v3.0/security/assessments.go | 407 + .../mgmt/v3.0/security/assessmentsmetadata.go | 588 + .../mgmt/v3.0/security/automations.go | 638 + .../v3.0/security/autoprovisioningsettings.go | 322 + .../security/mgmt/v3.0/security/client.go | 54 + .../mgmt/v3.0/security/complianceresults.go | 231 + .../mgmt/v3.0/security/compliances.go | 231 + .../security/mgmt/v3.0/security/connectors.go | 400 + .../security/mgmt/v3.0/security/contacts.go | 484 + .../v3.0/security/devicesecuritygroups.go | 383 + .../security/discoveredsecuritysolutions.go | 366 + .../security/mgmt/v3.0/security/enums.go | 1401 ++ .../security/externalsecuritysolutions.go | 366 + .../security/informationprotectionpolicies.go | 310 + .../security/mgmt/v3.0/security/iotalerts.go | 278 + .../mgmt/v3.0/security/iotalerttypes.go | 217 + .../mgmt/v3.0/security/iotrecommendations.go | 271 + .../v3.0/security/iotrecommendationtypes.go | 218 + .../mgmt/v3.0/security/iotsecuritysolution.go | 657 + .../security/iotsecuritysolutionanalytics.go | 216 + ...curitysolutionsanalyticsaggregatedalert.go | 353 + ...ecuritysolutionsanalyticsrecommendation.go | 267 + .../v3.0/security/jitnetworkaccesspolicies.go | 893 + .../security/mgmt/v3.0/security/locations.go | 239 + .../security/mgmt/v3.0/security/models.go | 18649 ++++++++++++++++ .../security/mgmt/v3.0/security/operations.go | 149 + .../security/mgmt/v3.0/security/pricings.go | 280 + .../regulatorycomplianceassessments.go | 254 + .../security/regulatorycompliancecontrols.go | 249 + .../security/regulatorycompliancestandards.go | 245 + .../security/securescorecontroldefinitions.go | 269 + .../mgmt/v3.0/security/securescorecontrols.go | 291 + .../mgmt/v3.0/security/securescores.go | 241 + .../security/servervulnerabilityassessment.go | 407 + .../security/mgmt/v3.0/security/settings.go | 321 + .../security/mgmt/v3.0/security/solutions.go | 247 + .../v3.0/security/solutionsreferencedata.go | 197 + .../mgmt/v3.0/security/subassessments.go | 349 + .../security/mgmt/v3.0/security/tasks.go | 756 + .../security/mgmt/v3.0/security/topology.go | 365 + .../security/mgmt/v3.0/security/version.go | 30 + .../mgmt/v3.0/security/workspacesettings.go | 489 + vendor/modules.txt | 1 + ...urity_center_subscription_pricing.markdown | 6 +- 60 files changed, 36651 insertions(+), 47 deletions(-) create mode 100644 azurerm/internal/services/securitycenter/parse/security_center_subscription_pricing.go create mode 100644 azurerm/internal/services/securitycenter/parse/security_center_subscription_pricing_test.go create mode 100644 azurerm/internal/services/securitycenter/resource_arm_security_center_subscription_pricing_migration.go create mode 100644 azurerm/internal/services/securitycenter/tests/resource_arm_security_center_subscription_pricing_migration_test.go create mode 100644 examples/security/securitycenter-pricing/main.tf create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/adaptiveapplicationcontrols.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/adaptivenetworkhardenings.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/advancedthreatprotection.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/alerts.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/alertssuppressionrules.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/allowedconnections.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/assessments.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/assessmentsmetadata.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/automations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/autoprovisioningsettings.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/complianceresults.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/compliances.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/connectors.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/contacts.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/devicesecuritygroups.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/discoveredsecuritysolutions.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/enums.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/externalsecuritysolutions.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/informationprotectionpolicies.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotalerts.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotalerttypes.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotrecommendations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotrecommendationtypes.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolution.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionanalytics.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalert.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendation.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/jitnetworkaccesspolicies.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/locations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/operations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/pricings.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycomplianceassessments.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycompliancecontrols.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycompliancestandards.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescorecontroldefinitions.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescorecontrols.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescores.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/servervulnerabilityassessment.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/settings.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/solutions.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/solutionsreferencedata.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/subassessments.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/tasks.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/topology.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/version.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/workspacesettings.go diff --git a/azurerm/internal/services/securitycenter/client/client.go b/azurerm/internal/services/securitycenter/client/client.go index c91e050c4c822..c682c800ef8ac 100644 --- a/azurerm/internal/services/securitycenter/client/client.go +++ b/azurerm/internal/services/securitycenter/client/client.go @@ -1,30 +1,31 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v1.0/security" + securityv1 "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v1.0/security" + securityv3 "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" ) type Client struct { - ContactsClient *security.ContactsClient - PricingClient *security.PricingsClient - WorkspaceClient *security.WorkspaceSettingsClient - AdvancedThreatProtectionClient *security.AdvancedThreatProtectionClient + ContactsClient *securityv1.ContactsClient + PricingClient *securityv3.PricingsClient + WorkspaceClient *securityv1.WorkspaceSettingsClient + AdvancedThreatProtectionClient *securityv1.AdvancedThreatProtectionClient } func NewClient(o *common.ClientOptions) *Client { ascLocation := "Global" - ContactsClient := security.NewContactsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) + ContactsClient := securityv1.NewContactsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) o.ConfigureClient(&ContactsClient.Client, o.ResourceManagerAuthorizer) - PricingClient := security.NewPricingsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) + PricingClient := securityv3.NewPricingsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) o.ConfigureClient(&PricingClient.Client, o.ResourceManagerAuthorizer) - WorkspaceClient := security.NewWorkspaceSettingsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) + WorkspaceClient := securityv1.NewWorkspaceSettingsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) o.ConfigureClient(&WorkspaceClient.Client, o.ResourceManagerAuthorizer) - AdvancedThreatProtectionClient := security.NewAdvancedThreatProtectionClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) + AdvancedThreatProtectionClient := securityv1.NewAdvancedThreatProtectionClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) o.ConfigureClient(&AdvancedThreatProtectionClient.Client, o.ResourceManagerAuthorizer) return &Client{ diff --git a/azurerm/internal/services/securitycenter/parse/security_center_subscription_pricing.go b/azurerm/internal/services/securitycenter/parse/security_center_subscription_pricing.go new file mode 100644 index 0000000000000..9300c603c88fa --- /dev/null +++ b/azurerm/internal/services/securitycenter/parse/security_center_subscription_pricing.go @@ -0,0 +1,30 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type SecurityCenterSubscriptionPricingId struct { + ResourceType string +} + +func SecurityCenterSubscriptionPricingID(input string) (*SecurityCenterSubscriptionPricingId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("unable to parse Security Center Subscription Pricing ID %q: %+v", input, err) + } + + pricing := SecurityCenterSubscriptionPricingId{} + + if pricing.ResourceType, err = id.PopSegment("pricings"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &pricing, nil +} diff --git a/azurerm/internal/services/securitycenter/parse/security_center_subscription_pricing_test.go b/azurerm/internal/services/securitycenter/parse/security_center_subscription_pricing_test.go new file mode 100644 index 0000000000000..7a362237ba122 --- /dev/null +++ b/azurerm/internal/services/securitycenter/parse/security_center_subscription_pricing_test.go @@ -0,0 +1,54 @@ +package parse + +import ( + "testing" +) + +func TestSecurityCenterSubscriptionPricingID(t *testing.T) { + testData := []struct { + ResourceType string + Input string + Error bool + Expect *SecurityCenterSubscriptionPricingId + }{ + { + ResourceType: "Empty", + Input: "", + Error: true, + }, + { + ResourceType: "No Pricings Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + ResourceType: "No Pricings Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/pricings/", + Error: true, + }, + { + ResourceType: "Security Center Subscription Pricing ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/pricings/VirtualMachines", + Expect: &SecurityCenterSubscriptionPricingId{ + ResourceType: "VirtualMachines", + }, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.ResourceType) + + actual, err := SecurityCenterSubscriptionPricingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.ResourceType != v.Expect.ResourceType { + t.Fatalf("Expected %q but got %q for ResourceType", v.Expect.ResourceType, actual.ResourceType) + } + } +} diff --git a/azurerm/internal/services/securitycenter/resource_arm_security_center_subscription_pricing.go b/azurerm/internal/services/securitycenter/resource_arm_security_center_subscription_pricing.go index 29cab0c324b5f..ffe2b3f72488c 100644 --- a/azurerm/internal/services/securitycenter/resource_arm_security_center_subscription_pricing.go +++ b/azurerm/internal/services/securitycenter/resource_arm_security_center_subscription_pricing.go @@ -5,18 +5,16 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v1.0/security" + "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/securitycenter/parse" + azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -// NOTE: seems default is the only valid pricing name: -// Code="InvalidInputJson" Message="Pricing name 'kt's price' is not allowed. Expected 'default' for this scope." -const securityCenterSubscriptionPricingName = "default" - func resourceArmSecurityCenterSubscriptionPricing() *schema.Resource { return &schema.Resource{ Create: resourceArmSecurityCenterSubscriptionPricingUpdate, @@ -24,9 +22,10 @@ func resourceArmSecurityCenterSubscriptionPricing() *schema.Resource { Update: resourceArmSecurityCenterSubscriptionPricingUpdate, Delete: resourceArmSecurityCenterSubscriptionPricingDelete, - Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, - }, + Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error { + _, err := parse.SecurityCenterSubscriptionPricingID(id) + return err + }), Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(60 * time.Minute), @@ -35,6 +34,15 @@ func resourceArmSecurityCenterSubscriptionPricing() *schema.Resource { Delete: schema.DefaultTimeout(60 * time.Minute), }, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: ResourceArmSecurityCenterSubscriptionPricingV0().CoreConfigSchema().ImpliedType(), + Upgrade: ResourceArmSecurityCenterSubscriptionPricingUpgradeV0ToV1, + Version: 0, + }, + }, + Schema: map[string]*schema.Schema{ "tier": { Type: schema.TypeString, @@ -44,6 +52,20 @@ func resourceArmSecurityCenterSubscriptionPricing() *schema.Resource { string(security.Standard), }, false), }, + "resource_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + "AppServices", + "ContainerRegistry", + "KeyVaults", + "KubernetesService", + "SqlServers", + "SqlServerVirtualMachines", + "StorageAccounts", + "VirtualMachines", + }, false), + }, }, } } @@ -53,8 +75,6 @@ func resourceArmSecurityCenterSubscriptionPricingUpdate(d *schema.ResourceData, ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - name := securityCenterSubscriptionPricingName - // not doing import check as afaik it always exists (cannot be deleted) // all this resource does is flip a boolean @@ -64,11 +84,13 @@ func resourceArmSecurityCenterSubscriptionPricingUpdate(d *schema.ResourceData, }, } - if _, err := client.UpdateSubscriptionPricing(ctx, name, pricing); err != nil { + resource_type := d.Get("resource_type").(string) + + if _, err := client.Update(ctx, resource_type, pricing); err != nil { return fmt.Errorf("Error creating/updating Security Center Subscription pricing: %+v", err) } - resp, err := client.GetSubscriptionPricing(ctx, name) + resp, err := client.Get(ctx, resource_type) if err != nil { return fmt.Errorf("Error reading Security Center Subscription pricing: %+v", err) } @@ -86,20 +108,26 @@ func resourceArmSecurityCenterSubscriptionPricingRead(d *schema.ResourceData, me ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - resp, err := client.GetSubscriptionPricing(ctx, securityCenterSubscriptionPricingName) + id, err := parse.SecurityCenterSubscriptionPricingID(d.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, id.ResourceType) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[DEBUG] Security Center Subscription was not found: %v", err) + log.Printf("[DEBUG] %q Security Center Subscription was not found: %v", id.ResourceType, err) d.SetId("") return nil } - return fmt.Errorf("Error reading Security Center Subscription pricing: %+v", err) + return fmt.Errorf("Error reading %q Security Center Subscription pricing: %+v", id.ResourceType, err) } if properties := resp.PricingProperties; properties != nil { d.Set("tier", properties.PricingTier) } + d.Set("resource_type", id.ResourceType) return nil } diff --git a/azurerm/internal/services/securitycenter/resource_arm_security_center_subscription_pricing_migration.go b/azurerm/internal/services/securitycenter/resource_arm_security_center_subscription_pricing_migration.go new file mode 100644 index 0000000000000..1f866e8df2ea9 --- /dev/null +++ b/azurerm/internal/services/securitycenter/resource_arm_security_center_subscription_pricing_migration.go @@ -0,0 +1,32 @@ +package securitycenter + +import ( + "log" + + "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" +) + +func ResourceArmSecurityCenterSubscriptionPricingV0() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tier": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(security.Free), + string(security.Standard), + }, false), + }, + }, + } +} + +func ResourceArmSecurityCenterSubscriptionPricingUpgradeV0ToV1(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + log.Println("[DEBUG] Migrating ResourceType from v0 to v1 format") + + rawState["resource_type"] = "VirtualMachines" + + return rawState, nil +} diff --git a/azurerm/internal/services/securitycenter/resource_arm_security_center_workspace.go b/azurerm/internal/services/securitycenter/resource_arm_security_center_workspace.go index d77bc0f67c8a6..460371015db57 100644 --- a/azurerm/internal/services/securitycenter/resource_arm_security_center_workspace.go +++ b/azurerm/internal/services/securitycenter/resource_arm_security_center_workspace.go @@ -1,11 +1,13 @@ package securitycenter import ( + "context" "fmt" "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v1.0/security" + securityv1 "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v1.0/security" + securityv3 "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -77,20 +79,18 @@ func resourceArmSecurityCenterWorkspaceCreateUpdate(d *schema.ResourceData, meta // get pricing tier, workspace can only be configured when tier is not Free. // API does not error, it just doesn't set the workspace scope - price, err := priceClient.GetSubscriptionPricing(ctx, securityCenterSubscriptionPricingName) + isPricingStandard, err := isPricingStandard(ctx, priceClient) + if err != nil { - return fmt.Errorf("Error reading Security Center Subscription pricing: %+v", err) + return fmt.Errorf("Error checking Security Center Subscription pricing tier %v", err) } - if price.PricingProperties == nil { - return fmt.Errorf("Security Center Subscription pricing propertier is nil") - } - if price.PricingProperties.PricingTier == security.Free { + if !isPricingStandard { return fmt.Errorf("Security Center Subscription workspace cannot be set when pricing tier is `Free`") } - contact := security.WorkspaceSetting{ - WorkspaceSettingProperties: &security.WorkspaceSettingProperties{ + contact := securityv1.WorkspaceSetting{ + WorkspaceSettingProperties: &securityv1.WorkspaceSettingProperties{ Scope: utils.String(d.Get("scope").(string)), WorkspaceID: utils.String(d.Get("workspace_id").(string)), }, @@ -137,12 +137,33 @@ func resourceArmSecurityCenterWorkspaceCreateUpdate(d *schema.ResourceData, meta } if d.IsNewResource() { - d.SetId(*resp.(security.WorkspaceSetting).ID) + d.SetId(*resp.(securityv1.WorkspaceSetting).ID) } return resourceArmSecurityCenterWorkspaceRead(d, meta) } +func isPricingStandard(ctx context.Context, priceClient *securityv3.PricingsClient) (bool, error) { + prices, err := priceClient.List(ctx) + if err != nil { + return false, fmt.Errorf("Error listing Security Center Subscription pricing: %+v", err) + } + + if prices.Value != nil { + for _, resourcePrice := range *prices.Value { + if resourcePrice.PricingProperties == nil { + return false, fmt.Errorf("%v Security Center Subscription pricing propertier is nil", *resourcePrice.Type) + } + + if resourcePrice.PricingProperties.PricingTier == securityv3.Standard { + return true, nil + } + } + } + + return false, nil +} + func resourceArmSecurityCenterWorkspaceRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*clients.Client).SecurityCenter.WorkspaceClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) diff --git a/azurerm/internal/services/securitycenter/tests/resource_arm_security_center_subscription_pricing_migration_test.go b/azurerm/internal/services/securitycenter/tests/resource_arm_security_center_subscription_pricing_migration_test.go new file mode 100644 index 0000000000000..63502e14f6c0f --- /dev/null +++ b/azurerm/internal/services/securitycenter/tests/resource_arm_security_center_subscription_pricing_migration_test.go @@ -0,0 +1,38 @@ +package tests + +import ( + "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/securitycenter" +) + +func TestAzureRMSecurityCenterSubscriptionPricingMigrateState(t *testing.T) { + cases := map[string]struct { + StateVersion int + InputAttributes map[string]interface{} + ExpectedResourceType string + }{ + "subscription_scope": { + StateVersion: 0, + InputAttributes: map[string]interface{}{ + "tier": "Free", + }, + ExpectedResourceType: "VirtualMachines", + }, + "managementGroup_scope": { + StateVersion: 0, + InputAttributes: map[string]interface{}{ + "tier": "Standard", + }, + ExpectedResourceType: "VirtualMachines", + }, + } + + for _, tc := range cases { + rawState, _ := securitycenter.ResourceArmSecurityCenterSubscriptionPricingUpgradeV0ToV1(tc.InputAttributes, nil) + + if rawState["resource_type"].(string) != tc.ExpectedResourceType { + t.Fatalf("ResourceType migration failed, expected %q, got: %q", tc.ExpectedResourceType, rawState["resource_type"].(string)) + } + } +} diff --git a/azurerm/internal/services/securitycenter/tests/resource_arm_security_center_subscription_pricing_test.go b/azurerm/internal/services/securitycenter/tests/resource_arm_security_center_subscription_pricing_test.go index b285d0413b2bd..37387dac8121c 100644 --- a/azurerm/internal/services/securitycenter/tests/resource_arm_security_center_subscription_pricing_test.go +++ b/azurerm/internal/services/securitycenter/tests/resource_arm_security_center_subscription_pricing_test.go @@ -20,7 +20,7 @@ func testAccAzureRMSecurityCenterSubscriptionPricing_update(t *testing.T) { Providers: acceptance.SupportedProviders, Steps: []resource.TestStep{ { - Config: testAccAzureRMSecurityCenterSubscriptionPricing_tier("Standard"), + Config: testAccAzureRMSecurityCenterSubscriptionPricing_tier("Standard", "AppServices"), Check: resource.ComposeTestCheckFunc( testCheckAzureRMSecurityCenterSubscriptionPricingExists(data.ResourceName), resource.TestCheckResourceAttr(data.ResourceName, "tier", "Standard"), @@ -28,7 +28,7 @@ func testAccAzureRMSecurityCenterSubscriptionPricing_update(t *testing.T) { }, data.ImportStep(), { - Config: testAccAzureRMSecurityCenterSubscriptionPricing_tier("Free"), + Config: testAccAzureRMSecurityCenterSubscriptionPricing_tier("Free", "AppServices"), Check: resource.ComposeTestCheckFunc( testCheckAzureRMSecurityCenterSubscriptionPricingExists(data.ResourceName), resource.TestCheckResourceAttr(data.ResourceName, "tier", "Free"), @@ -51,27 +51,28 @@ func testCheckAzureRMSecurityCenterSubscriptionPricingExists(resourceName string pricingName := rs.Primary.Attributes["pricings"] - resp, err := client.GetSubscriptionPricing(ctx, pricingName) + resp, err := client.Get(ctx, pricingName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return fmt.Errorf("Security Center Subscription Pricing %q was not found: %+v", pricingName, err) } - return fmt.Errorf("Bad: GetSubscriptionPricing: %+v", err) + return fmt.Errorf("Bad: Get: %+v", err) } return nil } } -func testAccAzureRMSecurityCenterSubscriptionPricing_tier(tier string) string { +func testAccAzureRMSecurityCenterSubscriptionPricing_tier(tier string, resource_type string) string { return fmt.Sprintf(` provider "azurerm" { features {} } resource "azurerm_security_center_subscription_pricing" "test" { - tier = "%s" + tier = "%s" + resource_type = "%s" } -`, tier) +`, tier, resource_type) } diff --git a/azurerm/internal/services/securitycenter/tests/resource_arm_security_center_workspace_test.go b/azurerm/internal/services/securitycenter/tests/resource_arm_security_center_workspace_test.go index c49b5950c546b..d48449757a388 100644 --- a/azurerm/internal/services/securitycenter/tests/resource_arm_security_center_workspace_test.go +++ b/azurerm/internal/services/securitycenter/tests/resource_arm_security_center_workspace_test.go @@ -32,7 +32,7 @@ func testAccAzureRMSecurityCenterWorkspace_basic(t *testing.T) { data.ImportStep(), { // reset pricing to free - Config: testAccAzureRMSecurityCenterSubscriptionPricing_tier("Free"), + Config: testAccAzureRMSecurityCenterSubscriptionPricing_tier("Free", "VirtualMachines"), }, }, }) @@ -60,7 +60,7 @@ func testAccAzureRMSecurityCenterWorkspace_requiresImport(t *testing.T) { }, { // reset pricing to free - Config: testAccAzureRMSecurityCenterSubscriptionPricing_tier("Free"), + Config: testAccAzureRMSecurityCenterSubscriptionPricing_tier("Free", "VirtualMachines"), }, }, }) @@ -92,7 +92,7 @@ func testAccAzureRMSecurityCenterWorkspace_update(t *testing.T) { data.ImportStep(), { // reset pricing to free - Config: testAccAzureRMSecurityCenterSubscriptionPricing_tier("Free"), + Config: testAccAzureRMSecurityCenterSubscriptionPricing_tier("Free", "VirtualMachines"), }, }, }) @@ -149,7 +149,8 @@ provider "azurerm" { } resource "azurerm_security_center_subscription_pricing" "test" { - tier = "Standard" + tier = "Standard" + resource_type = "VirtualMachines" } resource "azurerm_resource_group" "test" { diff --git a/examples/security/securitycenter-pricing/main.tf b/examples/security/securitycenter-pricing/main.tf new file mode 100644 index 0000000000000..06377e85163a3 --- /dev/null +++ b/examples/security/securitycenter-pricing/main.tf @@ -0,0 +1,8 @@ +provider "azurerm" { + features {} +} + +resource "azurerm_security_center_subscription_pricing" "example" { + tier = "Standard" + resource_type = "VirtualMachines" +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/adaptiveapplicationcontrols.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/adaptiveapplicationcontrols.go new file mode 100644 index 0000000000000..f379c8458ae15 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/adaptiveapplicationcontrols.go @@ -0,0 +1,376 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AdaptiveApplicationControlsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AdaptiveApplicationControlsClient struct { + BaseClient +} + +// NewAdaptiveApplicationControlsClient creates an instance of the AdaptiveApplicationControlsClient client. +func NewAdaptiveApplicationControlsClient(subscriptionID string, ascLocation string) AdaptiveApplicationControlsClient { + return NewAdaptiveApplicationControlsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAdaptiveApplicationControlsClientWithBaseURI creates an instance of the AdaptiveApplicationControlsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewAdaptiveApplicationControlsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AdaptiveApplicationControlsClient { + return AdaptiveApplicationControlsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Delete delete an application control machine group +// Parameters: +// groupName - name of an application control machine group +func (client AdaptiveApplicationControlsClient) Delete(ctx context.Context, groupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveApplicationControlsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AdaptiveApplicationControlsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AdaptiveApplicationControlsClient) DeletePreparer(ctx context.Context, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "groupName": autorest.Encode("path", groupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AdaptiveApplicationControlsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AdaptiveApplicationControlsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an application control VM/server group. +// Parameters: +// groupName - name of an application control machine group +func (client AdaptiveApplicationControlsClient) Get(ctx context.Context, groupName string) (result AdaptiveApplicationControlGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveApplicationControlsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AdaptiveApplicationControlsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AdaptiveApplicationControlsClient) GetPreparer(ctx context.Context, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "groupName": autorest.Encode("path", groupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AdaptiveApplicationControlsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AdaptiveApplicationControlsClient) GetResponder(resp *http.Response) (result AdaptiveApplicationControlGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of application control machine groups for the subscription. +// Parameters: +// includePathRecommendations - include the policy rules +// summary - return output in a summarized form +func (client AdaptiveApplicationControlsClient) List(ctx context.Context, includePathRecommendations *bool, summary *bool) (result AdaptiveApplicationControlGroups, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveApplicationControlsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AdaptiveApplicationControlsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, includePathRecommendations, summary) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AdaptiveApplicationControlsClient) ListPreparer(ctx context.Context, includePathRecommendations *bool, summary *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if includePathRecommendations != nil { + queryParameters["includePathRecommendations"] = autorest.Encode("query", *includePathRecommendations) + } + if summary != nil { + queryParameters["summary"] = autorest.Encode("query", *summary) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/applicationWhitelistings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AdaptiveApplicationControlsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AdaptiveApplicationControlsClient) ListResponder(resp *http.Response) (result AdaptiveApplicationControlGroups, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Put update an application control machine group +// Parameters: +// groupName - name of an application control machine group +func (client AdaptiveApplicationControlsClient) Put(ctx context.Context, groupName string, body AdaptiveApplicationControlGroup) (result AdaptiveApplicationControlGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveApplicationControlsClient.Put") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.AdaptiveApplicationControlGroupData", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AdaptiveApplicationControlsClient", "Put", err.Error()) + } + + req, err := client.PutPreparer(ctx, groupName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Put", nil, "Failure preparing request") + return + } + + resp, err := client.PutSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Put", resp, "Failure sending request") + return + } + + result, err = client.PutResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveApplicationControlsClient", "Put", resp, "Failure responding to request") + } + + return +} + +// PutPreparer prepares the Put request. +func (client AdaptiveApplicationControlsClient) PutPreparer(ctx context.Context, groupName string, body AdaptiveApplicationControlGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "groupName": autorest.Encode("path", groupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + body.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PutSender sends the Put request. The method will close the +// http.Response Body if it receives an error. +func (client AdaptiveApplicationControlsClient) PutSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// PutResponder handles the response to the Put request. The method always +// closes the http.Response Body. +func (client AdaptiveApplicationControlsClient) PutResponder(resp *http.Response) (result AdaptiveApplicationControlGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/adaptivenetworkhardenings.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/adaptivenetworkhardenings.go new file mode 100644 index 0000000000000..0c65f0b927d56 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/adaptivenetworkhardenings.go @@ -0,0 +1,364 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AdaptiveNetworkHardeningsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AdaptiveNetworkHardeningsClient struct { + BaseClient +} + +// NewAdaptiveNetworkHardeningsClient creates an instance of the AdaptiveNetworkHardeningsClient client. +func NewAdaptiveNetworkHardeningsClient(subscriptionID string, ascLocation string) AdaptiveNetworkHardeningsClient { + return NewAdaptiveNetworkHardeningsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAdaptiveNetworkHardeningsClientWithBaseURI creates an instance of the AdaptiveNetworkHardeningsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewAdaptiveNetworkHardeningsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AdaptiveNetworkHardeningsClient { + return AdaptiveNetworkHardeningsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Enforce enforces the given rules on the NSG(s) listed in the request +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +// adaptiveNetworkHardeningResourceName - the name of the Adaptive Network Hardening resource. +func (client AdaptiveNetworkHardeningsClient) Enforce(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string, body AdaptiveNetworkHardeningEnforceRequest) (result AdaptiveNetworkHardeningsEnforceFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsClient.Enforce") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.Rules", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "body.NetworkSecurityGroups", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AdaptiveNetworkHardeningsClient", "Enforce", err.Error()) + } + + req, err := client.EnforcePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, adaptiveNetworkHardeningResourceName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "Enforce", nil, "Failure preparing request") + return + } + + result, err = client.EnforceSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "Enforce", result.Response(), "Failure sending request") + return + } + + return +} + +// EnforcePreparer prepares the Enforce request. +func (client AdaptiveNetworkHardeningsClient) EnforcePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string, body AdaptiveNetworkHardeningEnforceRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "adaptiveNetworkHardeningEnforceAction": autorest.Encode("path", "enforce"), + "adaptiveNetworkHardeningResourceName": autorest.Encode("path", adaptiveNetworkHardeningResourceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// EnforceSender sends the Enforce request. The method will close the +// http.Response Body if it receives an error. +func (client AdaptiveNetworkHardeningsClient) EnforceSender(req *http.Request) (future AdaptiveNetworkHardeningsEnforceFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// EnforceResponder handles the response to the Enforce request. The method always +// closes the http.Response Body. +func (client AdaptiveNetworkHardeningsClient) EnforceResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a single Adaptive Network Hardening resource +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +// adaptiveNetworkHardeningResourceName - the name of the Adaptive Network Hardening resource. +func (client AdaptiveNetworkHardeningsClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string) (result AdaptiveNetworkHardening, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AdaptiveNetworkHardeningsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName, adaptiveNetworkHardeningResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AdaptiveNetworkHardeningsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, adaptiveNetworkHardeningResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "adaptiveNetworkHardeningResourceName": autorest.Encode("path", adaptiveNetworkHardeningResourceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AdaptiveNetworkHardeningsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AdaptiveNetworkHardeningsClient) GetResponder(resp *http.Response) (result AdaptiveNetworkHardening, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByExtendedResource gets a list of Adaptive Network Hardenings resources in scope of an extended resource. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +func (client AdaptiveNetworkHardeningsClient) ListByExtendedResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result AdaptiveNetworkHardeningsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsClient.ListByExtendedResource") + defer func() { + sc := -1 + if result.anhl.Response.Response != nil { + sc = result.anhl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AdaptiveNetworkHardeningsClient", "ListByExtendedResource", err.Error()) + } + + result.fn = client.listByExtendedResourceNextResults + req, err := client.ListByExtendedResourcePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "ListByExtendedResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListByExtendedResourceSender(req) + if err != nil { + result.anhl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "ListByExtendedResource", resp, "Failure sending request") + return + } + + result.anhl, err = client.ListByExtendedResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "ListByExtendedResource", resp, "Failure responding to request") + } + if result.anhl.hasNextLink() && result.anhl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByExtendedResourcePreparer prepares the ListByExtendedResource request. +func (client AdaptiveNetworkHardeningsClient) ListByExtendedResourcePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByExtendedResourceSender sends the ListByExtendedResource request. The method will close the +// http.Response Body if it receives an error. +func (client AdaptiveNetworkHardeningsClient) ListByExtendedResourceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByExtendedResourceResponder handles the response to the ListByExtendedResource request. The method always +// closes the http.Response Body. +func (client AdaptiveNetworkHardeningsClient) ListByExtendedResourceResponder(resp *http.Response) (result AdaptiveNetworkHardeningsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByExtendedResourceNextResults retrieves the next set of results, if any. +func (client AdaptiveNetworkHardeningsClient) listByExtendedResourceNextResults(ctx context.Context, lastResults AdaptiveNetworkHardeningsList) (result AdaptiveNetworkHardeningsList, err error) { + req, err := lastResults.adaptiveNetworkHardeningsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "listByExtendedResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByExtendedResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "listByExtendedResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByExtendedResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsClient", "listByExtendedResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByExtendedResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client AdaptiveNetworkHardeningsClient) ListByExtendedResourceComplete(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result AdaptiveNetworkHardeningsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsClient.ListByExtendedResource") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByExtendedResource(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/advancedthreatprotection.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/advancedthreatprotection.go new file mode 100644 index 0000000000000..826770efc977b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/advancedthreatprotection.go @@ -0,0 +1,192 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AdvancedThreatProtectionClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AdvancedThreatProtectionClient struct { + BaseClient +} + +// NewAdvancedThreatProtectionClient creates an instance of the AdvancedThreatProtectionClient client. +func NewAdvancedThreatProtectionClient(subscriptionID string, ascLocation string) AdvancedThreatProtectionClient { + return NewAdvancedThreatProtectionClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAdvancedThreatProtectionClientWithBaseURI creates an instance of the AdvancedThreatProtectionClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewAdvancedThreatProtectionClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AdvancedThreatProtectionClient { + return AdvancedThreatProtectionClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Create creates or updates the Advanced Threat Protection settings on a specified resource. +// Parameters: +// resourceID - the identifier of the resource. +// advancedThreatProtectionSetting - advanced Threat Protection Settings +func (client AdvancedThreatProtectionClient) Create(ctx context.Context, resourceID string, advancedThreatProtectionSetting AdvancedThreatProtectionSetting) (result AdvancedThreatProtectionSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdvancedThreatProtectionClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreatePreparer(ctx, resourceID, advancedThreatProtectionSetting) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdvancedThreatProtectionClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AdvancedThreatProtectionClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdvancedThreatProtectionClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client AdvancedThreatProtectionClient) CreatePreparer(ctx context.Context, resourceID string, advancedThreatProtectionSetting AdvancedThreatProtectionSetting) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceId": resourceID, + "settingName": autorest.Encode("path", "current"), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}", pathParameters), + autorest.WithJSON(advancedThreatProtectionSetting), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client AdvancedThreatProtectionClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client AdvancedThreatProtectionClient) CreateResponder(resp *http.Response) (result AdvancedThreatProtectionSetting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the Advanced Threat Protection settings for the specified resource. +// Parameters: +// resourceID - the identifier of the resource. +func (client AdvancedThreatProtectionClient) Get(ctx context.Context, resourceID string) (result AdvancedThreatProtectionSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdvancedThreatProtectionClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceID) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdvancedThreatProtectionClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AdvancedThreatProtectionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdvancedThreatProtectionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AdvancedThreatProtectionClient) GetPreparer(ctx context.Context, resourceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceId": resourceID, + "settingName": autorest.Encode("path", "current"), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AdvancedThreatProtectionClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AdvancedThreatProtectionClient) GetResponder(resp *http.Response) (result AdvancedThreatProtectionSetting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/alerts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/alerts.go new file mode 100644 index 0000000000000..e3aad94437469 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/alerts.go @@ -0,0 +1,1098 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AlertsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AlertsClient struct { + BaseClient +} + +// NewAlertsClient creates an instance of the AlertsClient client. +func NewAlertsClient(subscriptionID string, ascLocation string) AlertsClient { + return NewAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAlertsClientWithBaseURI creates an instance of the AlertsClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AlertsClient { + return AlertsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// GetResourceGroupLevelAlerts get an alert that is associated a resource group or a resource in a resource group +// Parameters: +// alertName - name of the alert object +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) GetResourceGroupLevelAlerts(ctx context.Context, alertName string, resourceGroupName string) (result Alert, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.GetResourceGroupLevelAlerts") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "GetResourceGroupLevelAlerts", err.Error()) + } + + req, err := client.GetResourceGroupLevelAlertsPreparer(ctx, alertName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetResourceGroupLevelAlerts", nil, "Failure preparing request") + return + } + + resp, err := client.GetResourceGroupLevelAlertsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetResourceGroupLevelAlerts", resp, "Failure sending request") + return + } + + result, err = client.GetResourceGroupLevelAlertsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetResourceGroupLevelAlerts", resp, "Failure responding to request") + } + + return +} + +// GetResourceGroupLevelAlertsPreparer prepares the GetResourceGroupLevelAlerts request. +func (client AlertsClient) GetResourceGroupLevelAlertsPreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetResourceGroupLevelAlertsSender sends the GetResourceGroupLevelAlerts request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) GetResourceGroupLevelAlertsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResourceGroupLevelAlertsResponder handles the response to the GetResourceGroupLevelAlerts request. The method always +// closes the http.Response Body. +func (client AlertsClient) GetResourceGroupLevelAlertsResponder(resp *http.Response) (result Alert, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSubscriptionLevelAlert get an alert that is associated with a subscription +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) GetSubscriptionLevelAlert(ctx context.Context, alertName string) (result Alert, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.GetSubscriptionLevelAlert") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "GetSubscriptionLevelAlert", err.Error()) + } + + req, err := client.GetSubscriptionLevelAlertPreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetSubscriptionLevelAlert", nil, "Failure preparing request") + return + } + + resp, err := client.GetSubscriptionLevelAlertSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetSubscriptionLevelAlert", resp, "Failure sending request") + return + } + + result, err = client.GetSubscriptionLevelAlertResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "GetSubscriptionLevelAlert", resp, "Failure responding to request") + } + + return +} + +// GetSubscriptionLevelAlertPreparer prepares the GetSubscriptionLevelAlert request. +func (client AlertsClient) GetSubscriptionLevelAlertPreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSubscriptionLevelAlertSender sends the GetSubscriptionLevelAlert request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) GetSubscriptionLevelAlertSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSubscriptionLevelAlertResponder handles the response to the GetSubscriptionLevelAlert request. The method always +// closes the http.Response Body. +func (client AlertsClient) GetSubscriptionLevelAlertResponder(resp *http.Response) (result Alert, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list all the alerts that are associated with the subscription +// Parameters: +// filter - oData filter. Optional. +// selectParameter - oData select. Optional. +// expand - oData expand. Optional. +// autoDismissRuleName - the name of an existing auto dismiss rule. Use it to simulate the rule on existing +// alerts and get the alerts that would have been dismissed if the rule was enabled when the alert was created +func (client AlertsClient) List(ctx context.Context, filter string, selectParameter string, expand string, autoDismissRuleName string) (result AlertListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.List") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, filter, selectParameter, expand, autoDismissRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AlertsClient", "List", resp, "Failure sending request") + return + } + + result.al, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "List", resp, "Failure responding to request") + } + if result.al.hasNextLink() && result.al.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client AlertsClient) ListPreparer(ctx context.Context, filter string, selectParameter string, expand string, autoDismissRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(autoDismissRuleName) > 0 { + queryParameters["autoDismissRuleName"] = autorest.Encode("query", autoDismissRuleName) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/alerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AlertsClient) ListResponder(resp *http.Response) (result AlertList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AlertsClient) listNextResults(ctx context.Context, lastResults AlertList) (result AlertList, err error) { + req, err := lastResults.alertListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AlertsClient) ListComplete(ctx context.Context, filter string, selectParameter string, expand string, autoDismissRuleName string) (result AlertListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, filter, selectParameter, expand, autoDismissRuleName) + return +} + +// ListByResourceGroup list all the alerts that are associated with the resource group +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// filter - oData filter. Optional. +// selectParameter - oData select. Optional. +// expand - oData expand. Optional. +// autoDismissRuleName - the name of an existing auto dismiss rule. Use it to simulate the rule on existing +// alerts and get the alerts that would have been dismissed if the rule was enabled when the alert was created +func (client AlertsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string, autoDismissRuleName string) (result AlertListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, selectParameter, expand, autoDismissRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.al, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.al.hasNextLink() && result.al.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AlertsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string, autoDismissRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(autoDismissRuleName) > 0 { + queryParameters["autoDismissRuleName"] = autorest.Encode("query", autoDismissRuleName) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/alerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AlertsClient) ListByResourceGroupResponder(resp *http.Response) (result AlertList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client AlertsClient) listByResourceGroupNextResults(ctx context.Context, lastResults AlertList) (result AlertList, err error) { + req, err := lastResults.alertListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client AlertsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string, autoDismissRuleName string) (result AlertListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter, selectParameter, expand, autoDismissRuleName) + return +} + +// ListResourceGroupLevelAlertsByRegion list all the alerts that are associated with the resource group that are stored +// in a specific location +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// filter - oData filter. Optional. +// selectParameter - oData select. Optional. +// expand - oData expand. Optional. +// autoDismissRuleName - the name of an existing auto dismiss rule. Use it to simulate the rule on existing +// alerts and get the alerts that would have been dismissed if the rule was enabled when the alert was created +func (client AlertsClient) ListResourceGroupLevelAlertsByRegion(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string, autoDismissRuleName string) (result AlertListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListResourceGroupLevelAlertsByRegion") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "ListResourceGroupLevelAlertsByRegion", err.Error()) + } + + result.fn = client.listResourceGroupLevelAlertsByRegionNextResults + req, err := client.ListResourceGroupLevelAlertsByRegionPreparer(ctx, resourceGroupName, filter, selectParameter, expand, autoDismissRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListResourceGroupLevelAlertsByRegion", nil, "Failure preparing request") + return + } + + resp, err := client.ListResourceGroupLevelAlertsByRegionSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListResourceGroupLevelAlertsByRegion", resp, "Failure sending request") + return + } + + result.al, err = client.ListResourceGroupLevelAlertsByRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListResourceGroupLevelAlertsByRegion", resp, "Failure responding to request") + } + if result.al.hasNextLink() && result.al.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListResourceGroupLevelAlertsByRegionPreparer prepares the ListResourceGroupLevelAlertsByRegion request. +func (client AlertsClient) ListResourceGroupLevelAlertsByRegionPreparer(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string, autoDismissRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(autoDismissRuleName) > 0 { + queryParameters["autoDismissRuleName"] = autorest.Encode("query", autoDismissRuleName) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListResourceGroupLevelAlertsByRegionSender sends the ListResourceGroupLevelAlertsByRegion request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) ListResourceGroupLevelAlertsByRegionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResourceGroupLevelAlertsByRegionResponder handles the response to the ListResourceGroupLevelAlertsByRegion request. The method always +// closes the http.Response Body. +func (client AlertsClient) ListResourceGroupLevelAlertsByRegionResponder(resp *http.Response) (result AlertList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listResourceGroupLevelAlertsByRegionNextResults retrieves the next set of results, if any. +func (client AlertsClient) listResourceGroupLevelAlertsByRegionNextResults(ctx context.Context, lastResults AlertList) (result AlertList, err error) { + req, err := lastResults.alertListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listResourceGroupLevelAlertsByRegionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListResourceGroupLevelAlertsByRegionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listResourceGroupLevelAlertsByRegionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResourceGroupLevelAlertsByRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "listResourceGroupLevelAlertsByRegionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListResourceGroupLevelAlertsByRegionComplete enumerates all values, automatically crossing page boundaries as required. +func (client AlertsClient) ListResourceGroupLevelAlertsByRegionComplete(ctx context.Context, resourceGroupName string, filter string, selectParameter string, expand string, autoDismissRuleName string) (result AlertListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListResourceGroupLevelAlertsByRegion") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListResourceGroupLevelAlertsByRegion(ctx, resourceGroupName, filter, selectParameter, expand, autoDismissRuleName) + return +} + +// ListSubscriptionLevelAlertsByRegion list all the alerts that are associated with the subscription that are stored in +// a specific location +// Parameters: +// filter - oData filter. Optional. +// selectParameter - oData select. Optional. +// expand - oData expand. Optional. +// autoDismissRuleName - the name of an existing auto dismiss rule. Use it to simulate the rule on existing +// alerts and get the alerts that would have been dismissed if the rule was enabled when the alert was created +func (client AlertsClient) ListSubscriptionLevelAlertsByRegion(ctx context.Context, filter string, selectParameter string, expand string, autoDismissRuleName string) (result AlertListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListSubscriptionLevelAlertsByRegion") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "ListSubscriptionLevelAlertsByRegion", err.Error()) + } + + result.fn = client.listSubscriptionLevelAlertsByRegionNextResults + req, err := client.ListSubscriptionLevelAlertsByRegionPreparer(ctx, filter, selectParameter, expand, autoDismissRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListSubscriptionLevelAlertsByRegion", nil, "Failure preparing request") + return + } + + resp, err := client.ListSubscriptionLevelAlertsByRegionSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListSubscriptionLevelAlertsByRegion", resp, "Failure sending request") + return + } + + result.al, err = client.ListSubscriptionLevelAlertsByRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "ListSubscriptionLevelAlertsByRegion", resp, "Failure responding to request") + } + if result.al.hasNextLink() && result.al.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListSubscriptionLevelAlertsByRegionPreparer prepares the ListSubscriptionLevelAlertsByRegion request. +func (client AlertsClient) ListSubscriptionLevelAlertsByRegionPreparer(ctx context.Context, filter string, selectParameter string, expand string, autoDismissRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(autoDismissRuleName) > 0 { + queryParameters["autoDismissRuleName"] = autorest.Encode("query", autoDismissRuleName) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSubscriptionLevelAlertsByRegionSender sends the ListSubscriptionLevelAlertsByRegion request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) ListSubscriptionLevelAlertsByRegionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSubscriptionLevelAlertsByRegionResponder handles the response to the ListSubscriptionLevelAlertsByRegion request. The method always +// closes the http.Response Body. +func (client AlertsClient) ListSubscriptionLevelAlertsByRegionResponder(resp *http.Response) (result AlertList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listSubscriptionLevelAlertsByRegionNextResults retrieves the next set of results, if any. +func (client AlertsClient) listSubscriptionLevelAlertsByRegionNextResults(ctx context.Context, lastResults AlertList) (result AlertList, err error) { + req, err := lastResults.alertListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listSubscriptionLevelAlertsByRegionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSubscriptionLevelAlertsByRegionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AlertsClient", "listSubscriptionLevelAlertsByRegionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListSubscriptionLevelAlertsByRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "listSubscriptionLevelAlertsByRegionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListSubscriptionLevelAlertsByRegionComplete enumerates all values, automatically crossing page boundaries as required. +func (client AlertsClient) ListSubscriptionLevelAlertsByRegionComplete(ctx context.Context, filter string, selectParameter string, expand string, autoDismissRuleName string) (result AlertListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListSubscriptionLevelAlertsByRegion") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListSubscriptionLevelAlertsByRegion(ctx, filter, selectParameter, expand, autoDismissRuleName) + return +} + +// UpdateResourceGroupLevelAlertStateToDismiss update the alert's state +// Parameters: +// alertName - name of the alert object +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismiss(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertStateToDismiss") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", err.Error()) + } + + req, err := client.UpdateResourceGroupLevelAlertStateToDismissPreparer(ctx, alertName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateResourceGroupLevelAlertStateToDismissSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", resp, "Failure sending request") + return + } + + result, err = client.UpdateResourceGroupLevelAlertStateToDismissResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToDismiss", resp, "Failure responding to request") + } + + return +} + +// UpdateResourceGroupLevelAlertStateToDismissPreparer prepares the UpdateResourceGroupLevelAlertStateToDismiss request. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissPreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateResourceGroupLevelAlertStateToDismissSender sends the UpdateResourceGroupLevelAlertStateToDismiss request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResourceGroupLevelAlertStateToDismissResponder handles the response to the UpdateResourceGroupLevelAlertStateToDismiss request. The method always +// closes the http.Response Body. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToDismissResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateResourceGroupLevelAlertStateToReactivate update the alert's state +// Parameters: +// alertName - name of the alert object +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivate(ctx context.Context, alertName string, resourceGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateResourceGroupLevelAlertStateToReactivate") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", err.Error()) + } + + req, err := client.UpdateResourceGroupLevelAlertStateToReactivatePreparer(ctx, alertName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateResourceGroupLevelAlertStateToReactivateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", resp, "Failure sending request") + return + } + + result, err = client.UpdateResourceGroupLevelAlertStateToReactivateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateResourceGroupLevelAlertStateToReactivate", resp, "Failure responding to request") + } + + return +} + +// UpdateResourceGroupLevelAlertStateToReactivatePreparer prepares the UpdateResourceGroupLevelAlertStateToReactivate request. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivatePreparer(ctx context.Context, alertName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateResourceGroupLevelAlertStateToReactivateSender sends the UpdateResourceGroupLevelAlertStateToReactivate request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResourceGroupLevelAlertStateToReactivateResponder handles the response to the UpdateResourceGroupLevelAlertStateToReactivate request. The method always +// closes the http.Response Body. +func (client AlertsClient) UpdateResourceGroupLevelAlertStateToReactivateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateSubscriptionLevelAlertStateToDismiss update the alert's state +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismiss(ctx context.Context, alertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertStateToDismiss") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", err.Error()) + } + + req, err := client.UpdateSubscriptionLevelAlertStateToDismissPreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSubscriptionLevelAlertStateToDismissSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", resp, "Failure sending request") + return + } + + result, err = client.UpdateSubscriptionLevelAlertStateToDismissResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToDismiss", resp, "Failure responding to request") + } + + return +} + +// UpdateSubscriptionLevelAlertStateToDismissPreparer prepares the UpdateSubscriptionLevelAlertStateToDismiss request. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissPreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSubscriptionLevelAlertStateToDismissSender sends the UpdateSubscriptionLevelAlertStateToDismiss request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateSubscriptionLevelAlertStateToDismissResponder handles the response to the UpdateSubscriptionLevelAlertStateToDismiss request. The method always +// closes the http.Response Body. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToDismissResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateSubscriptionLevelAlertStateToReactivate update the alert's state +// Parameters: +// alertName - name of the alert object +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivate(ctx context.Context, alertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.UpdateSubscriptionLevelAlertStateToReactivate") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", err.Error()) + } + + req, err := client.UpdateSubscriptionLevelAlertStateToReactivatePreparer(ctx, alertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSubscriptionLevelAlertStateToReactivateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", resp, "Failure sending request") + return + } + + result, err = client.UpdateSubscriptionLevelAlertStateToReactivateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsClient", "UpdateSubscriptionLevelAlertStateToReactivate", resp, "Failure responding to request") + } + + return +} + +// UpdateSubscriptionLevelAlertStateToReactivatePreparer prepares the UpdateSubscriptionLevelAlertStateToReactivate request. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivatePreparer(ctx context.Context, alertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertName": autorest.Encode("path", alertName), + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/reactivate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSubscriptionLevelAlertStateToReactivateSender sends the UpdateSubscriptionLevelAlertStateToReactivate request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateSubscriptionLevelAlertStateToReactivateResponder handles the response to the UpdateSubscriptionLevelAlertStateToReactivate request. The method always +// closes the http.Response Body. +func (client AlertsClient) UpdateSubscriptionLevelAlertStateToReactivateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/alertssuppressionrules.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/alertssuppressionrules.go new file mode 100644 index 0000000000000..74f0e82f8e8a8 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/alertssuppressionrules.go @@ -0,0 +1,412 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AlertsSuppressionRulesClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AlertsSuppressionRulesClient struct { + BaseClient +} + +// NewAlertsSuppressionRulesClient creates an instance of the AlertsSuppressionRulesClient client. +func NewAlertsSuppressionRulesClient(subscriptionID string, ascLocation string) AlertsSuppressionRulesClient { + return NewAlertsSuppressionRulesClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAlertsSuppressionRulesClientWithBaseURI creates an instance of the AlertsSuppressionRulesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewAlertsSuppressionRulesClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AlertsSuppressionRulesClient { + return AlertsSuppressionRulesClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Delete delete dismiss alert rule for this subscription. +// Parameters: +// alertsSuppressionRuleName - the unique name of the suppression alert rule +func (client AlertsSuppressionRulesClient) Delete(ctx context.Context, alertsSuppressionRuleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsSuppressionRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsSuppressionRulesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, alertsSuppressionRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AlertsSuppressionRulesClient) DeletePreparer(ctx context.Context, alertsSuppressionRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertsSuppressionRuleName": autorest.Encode("path", alertsSuppressionRuleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsSuppressionRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AlertsSuppressionRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get dismiss rule, with name: {alertsSuppressionRuleName}, for the given subscription +// Parameters: +// alertsSuppressionRuleName - the unique name of the suppression alert rule +func (client AlertsSuppressionRulesClient) Get(ctx context.Context, alertsSuppressionRuleName string) (result AlertsSuppressionRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsSuppressionRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsSuppressionRulesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, alertsSuppressionRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AlertsSuppressionRulesClient) GetPreparer(ctx context.Context, alertsSuppressionRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertsSuppressionRuleName": autorest.Encode("path", alertsSuppressionRuleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsSuppressionRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AlertsSuppressionRulesClient) GetResponder(resp *http.Response) (result AlertsSuppressionRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list of all the dismiss rules for the given subscription +// Parameters: +// alertType - type of the alert to get rules for +func (client AlertsSuppressionRulesClient) List(ctx context.Context, alertType string) (result AlertsSuppressionRulesListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsSuppressionRulesClient.List") + defer func() { + sc := -1 + if result.asrl.Response.Response != nil { + sc = result.asrl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AlertsSuppressionRulesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, alertType) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.asrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "List", resp, "Failure sending request") + return + } + + result.asrl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "List", resp, "Failure responding to request") + } + if result.asrl.hasNextLink() && result.asrl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client AlertsSuppressionRulesClient) ListPreparer(ctx context.Context, alertType string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(alertType) > 0 { + queryParameters["AlertType"] = autorest.Encode("query", alertType) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsSuppressionRulesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AlertsSuppressionRulesClient) ListResponder(resp *http.Response) (result AlertsSuppressionRulesList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AlertsSuppressionRulesClient) listNextResults(ctx context.Context, lastResults AlertsSuppressionRulesList) (result AlertsSuppressionRulesList, err error) { + req, err := lastResults.alertsSuppressionRulesListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AlertsSuppressionRulesClient) ListComplete(ctx context.Context, alertType string) (result AlertsSuppressionRulesListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsSuppressionRulesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, alertType) + return +} + +// Update update existing rule or create new rule if it doesn't exist +// Parameters: +// alertsSuppressionRuleName - the unique name of the suppression alert rule +// alertsSuppressionRule - suppression rule object +func (client AlertsSuppressionRulesClient) Update(ctx context.Context, alertsSuppressionRuleName string, alertsSuppressionRule AlertsSuppressionRule) (result AlertsSuppressionRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsSuppressionRulesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: alertsSuppressionRule, + Constraints: []validation.Constraint{{Target: "alertsSuppressionRule.AlertsSuppressionRuleProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "alertsSuppressionRule.AlertsSuppressionRuleProperties.AlertType", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "alertsSuppressionRule.AlertsSuppressionRuleProperties.Reason", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "alertsSuppressionRule.AlertsSuppressionRuleProperties.SuppressionAlertsScope", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "alertsSuppressionRule.AlertsSuppressionRuleProperties.SuppressionAlertsScope.AllOf", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("security.AlertsSuppressionRulesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, alertsSuppressionRuleName, alertsSuppressionRule) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AlertsSuppressionRulesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AlertsSuppressionRulesClient) UpdatePreparer(ctx context.Context, alertsSuppressionRuleName string, alertsSuppressionRule AlertsSuppressionRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertsSuppressionRuleName": autorest.Encode("path", alertsSuppressionRuleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}", pathParameters), + autorest.WithJSON(alertsSuppressionRule), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsSuppressionRulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AlertsSuppressionRulesClient) UpdateResponder(resp *http.Response) (result AlertsSuppressionRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/allowedconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/allowedconnections.go new file mode 100644 index 0000000000000..6b31cf895d9ad --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/allowedconnections.go @@ -0,0 +1,367 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AllowedConnectionsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AllowedConnectionsClient struct { + BaseClient +} + +// NewAllowedConnectionsClient creates an instance of the AllowedConnectionsClient client. +func NewAllowedConnectionsClient(subscriptionID string, ascLocation string) AllowedConnectionsClient { + return NewAllowedConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAllowedConnectionsClientWithBaseURI creates an instance of the AllowedConnectionsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAllowedConnectionsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AllowedConnectionsClient { + return AllowedConnectionsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get gets the list of all possible traffic between resources for the subscription and location, based on connection +// type. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// connectionType - the type of allowed connections (Internal, External) +func (client AllowedConnectionsClient) Get(ctx context.Context, resourceGroupName string, connectionType ConnectionType) (result AllowedConnectionsResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AllowedConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AllowedConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, connectionType) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AllowedConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, connectionType ConnectionType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "connectionType": autorest.Encode("path", connectionType), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AllowedConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AllowedConnectionsClient) GetResponder(resp *http.Response) (result AllowedConnectionsResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the list of all possible traffic between resources for the subscription +func (client AllowedConnectionsClient) List(ctx context.Context) (result AllowedConnectionsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AllowedConnectionsClient.List") + defer func() { + sc := -1 + if result.ACL.Response.Response != nil { + sc = result.ACL.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AllowedConnectionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ACL.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "List", resp, "Failure sending request") + return + } + + result.ACL, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "List", resp, "Failure responding to request") + } + if result.ACL.hasNextLink() && result.ACL.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client AllowedConnectionsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/allowedConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AllowedConnectionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AllowedConnectionsClient) ListResponder(resp *http.Response) (result AllowedConnectionsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AllowedConnectionsClient) listNextResults(ctx context.Context, lastResults AllowedConnectionsList) (result AllowedConnectionsList, err error) { + req, err := lastResults.allowedConnectionsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AllowedConnectionsClient) ListComplete(ctx context.Context) (result AllowedConnectionsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AllowedConnectionsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByHomeRegion gets the list of all possible traffic between resources for the subscription and location. +func (client AllowedConnectionsClient) ListByHomeRegion(ctx context.Context) (result AllowedConnectionsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AllowedConnectionsClient.ListByHomeRegion") + defer func() { + sc := -1 + if result.ACL.Response.Response != nil { + sc = result.ACL.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AllowedConnectionsClient", "ListByHomeRegion", err.Error()) + } + + result.fn = client.listByHomeRegionNextResults + req, err := client.ListByHomeRegionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "ListByHomeRegion", nil, "Failure preparing request") + return + } + + resp, err := client.ListByHomeRegionSender(req) + if err != nil { + result.ACL.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "ListByHomeRegion", resp, "Failure sending request") + return + } + + result.ACL, err = client.ListByHomeRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "ListByHomeRegion", resp, "Failure responding to request") + } + if result.ACL.hasNextLink() && result.ACL.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByHomeRegionPreparer prepares the ListByHomeRegion request. +func (client AllowedConnectionsClient) ListByHomeRegionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByHomeRegionSender sends the ListByHomeRegion request. The method will close the +// http.Response Body if it receives an error. +func (client AllowedConnectionsClient) ListByHomeRegionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByHomeRegionResponder handles the response to the ListByHomeRegion request. The method always +// closes the http.Response Body. +func (client AllowedConnectionsClient) ListByHomeRegionResponder(resp *http.Response) (result AllowedConnectionsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByHomeRegionNextResults retrieves the next set of results, if any. +func (client AllowedConnectionsClient) listByHomeRegionNextResults(ctx context.Context, lastResults AllowedConnectionsList) (result AllowedConnectionsList, err error) { + req, err := lastResults.allowedConnectionsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "listByHomeRegionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByHomeRegionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "listByHomeRegionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByHomeRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AllowedConnectionsClient", "listByHomeRegionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByHomeRegionComplete enumerates all values, automatically crossing page boundaries as required. +func (client AllowedConnectionsClient) ListByHomeRegionComplete(ctx context.Context) (result AllowedConnectionsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AllowedConnectionsClient.ListByHomeRegion") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByHomeRegion(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/assessments.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/assessments.go new file mode 100644 index 0000000000000..f7596ec0c99a8 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/assessments.go @@ -0,0 +1,407 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AssessmentsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AssessmentsClient struct { + BaseClient +} + +// NewAssessmentsClient creates an instance of the AssessmentsClient client. +func NewAssessmentsClient(subscriptionID string, ascLocation string) AssessmentsClient { + return NewAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAssessmentsClientWithBaseURI creates an instance of the AssessmentsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAssessmentsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsClient { + return AssessmentsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// CreateOrUpdate create a security assessment on your resource. An assessment metadata that describes this assessment +// must be predefined with the same name before inserting the assessment result +// Parameters: +// resourceID - the identifier of the resource. +// assessmentName - the Assessment Key - Unique key for the assessment type +// assessment - calculated assessment on a pre-defined assessment metadata +func (client AssessmentsClient) CreateOrUpdate(ctx context.Context, resourceID string, assessmentName string, assessment Assessment) (result Assessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: assessment, + Constraints: []validation.Constraint{{Target: "assessment.AssessmentProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "assessment.AssessmentProperties.ResourceDetails", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "assessment.AssessmentProperties.Status", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "assessment.AssessmentProperties.Metadata", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "assessment.AssessmentProperties.Metadata.DisplayName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "assessment.AssessmentProperties.Metadata.PartnerData", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "assessment.AssessmentProperties.Metadata.PartnerData.PartnerName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "assessment.AssessmentProperties.Metadata.PartnerData.Secret", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "assessment.AssessmentProperties.PartnersData", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "assessment.AssessmentProperties.PartnersData.PartnerName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "assessment.AssessmentProperties.PartnersData.Secret", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("security.AssessmentsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceID, assessmentName, assessment) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AssessmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceID string, assessmentName string, assessment Assessment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentName": autorest.Encode("path", assessmentName), + "resourceId": resourceID, + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}", pathParameters), + autorest.WithJSON(assessment), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AssessmentsClient) CreateOrUpdateResponder(resp *http.Response) (result Assessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a security assessment on your resource. An assessment metadata that describes this assessment must be +// predefined with the same name before inserting the assessment result +// Parameters: +// resourceID - the identifier of the resource. +// assessmentName - the Assessment Key - Unique key for the assessment type +func (client AssessmentsClient) Delete(ctx context.Context, resourceID string, assessmentName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceID, assessmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AssessmentsClient) DeletePreparer(ctx context.Context, resourceID string, assessmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentName": autorest.Encode("path", assessmentName), + "resourceId": resourceID, + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AssessmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a security assessment on your scanned resource +// Parameters: +// resourceID - the identifier of the resource. +// assessmentName - the Assessment Key - Unique key for the assessment type +// expand - oData expand. Optional. +func (client AssessmentsClient) Get(ctx context.Context, resourceID string, assessmentName string, expand ExpandEnum) (result Assessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceID, assessmentName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AssessmentsClient) GetPreparer(ctx context.Context, resourceID string, assessmentName string, expand ExpandEnum) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentName": autorest.Encode("path", assessmentName), + "resourceId": resourceID, + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(expand)) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AssessmentsClient) GetResponder(resp *http.Response) (result Assessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get security assessments on all your scanned resources inside a scope +// Parameters: +// scope - scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or +// management group (/providers/Microsoft.Management/managementGroups/mgName). +func (client AssessmentsClient) List(ctx context.Context, scope string) (result AssessmentListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsClient.List") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "List", resp, "Failure sending request") + return + } + + result.al, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "List", resp, "Failure responding to request") + } + if result.al.hasNextLink() && result.al.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client AssessmentsClient) ListPreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Security/assessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AssessmentsClient) ListResponder(resp *http.Response) (result AssessmentList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AssessmentsClient) listNextResults(ctx context.Context, lastResults AssessmentList) (result AssessmentList, err error) { + req, err := lastResults.assessmentListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AssessmentsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AssessmentsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AssessmentsClient) ListComplete(ctx context.Context, scope string) (result AssessmentListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, scope) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/assessmentsmetadata.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/assessmentsmetadata.go new file mode 100644 index 0000000000000..629f77b33208b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/assessmentsmetadata.go @@ -0,0 +1,588 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AssessmentsMetadataClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AssessmentsMetadataClient struct { + BaseClient +} + +// NewAssessmentsMetadataClient creates an instance of the AssessmentsMetadataClient client. +func NewAssessmentsMetadataClient(subscriptionID string, ascLocation string) AssessmentsMetadataClient { + return NewAssessmentsMetadataClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAssessmentsMetadataClientWithBaseURI creates an instance of the AssessmentsMetadataClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAssessmentsMetadataClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AssessmentsMetadataClient { + return AssessmentsMetadataClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// CreateInSubscription create metadata information on an assessment type in a specific subscription +// Parameters: +// assessmentMetadataName - the Assessment Key - Unique key for the assessment type +// assessmentMetadata - assessmentMetadata object +func (client AssessmentsMetadataClient) CreateInSubscription(ctx context.Context, assessmentMetadataName string, assessmentMetadata AssessmentMetadata) (result AssessmentMetadata, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.CreateInSubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: assessmentMetadata, + Constraints: []validation.Constraint{{Target: "assessmentMetadata.AssessmentMetadataProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "assessmentMetadata.AssessmentMetadataProperties.DisplayName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "assessmentMetadata.AssessmentMetadataProperties.PartnerData", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "assessmentMetadata.AssessmentMetadataProperties.PartnerData.PartnerName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "assessmentMetadata.AssessmentMetadataProperties.PartnerData.Secret", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("security.AssessmentsMetadataClient", "CreateInSubscription", err.Error()) + } + + req, err := client.CreateInSubscriptionPreparer(ctx, assessmentMetadataName, assessmentMetadata) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "CreateInSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.CreateInSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "CreateInSubscription", resp, "Failure sending request") + return + } + + result, err = client.CreateInSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "CreateInSubscription", resp, "Failure responding to request") + } + + return +} + +// CreateInSubscriptionPreparer prepares the CreateInSubscription request. +func (client AssessmentsMetadataClient) CreateInSubscriptionPreparer(ctx context.Context, assessmentMetadataName string, assessmentMetadata AssessmentMetadata) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentMetadataName": autorest.Encode("path", assessmentMetadataName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", pathParameters), + autorest.WithJSON(assessmentMetadata), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateInSubscriptionSender sends the CreateInSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataClient) CreateInSubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateInSubscriptionResponder handles the response to the CreateInSubscription request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) CreateInSubscriptionResponder(resp *http.Response) (result AssessmentMetadata, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteInSubscription delete metadata information on an assessment type in a specific subscription, will cause the +// deletion of all the assessments of that type in that subscription +// Parameters: +// assessmentMetadataName - the Assessment Key - Unique key for the assessment type +func (client AssessmentsMetadataClient) DeleteInSubscription(ctx context.Context, assessmentMetadataName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.DeleteInSubscription") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AssessmentsMetadataClient", "DeleteInSubscription", err.Error()) + } + + req, err := client.DeleteInSubscriptionPreparer(ctx, assessmentMetadataName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "DeleteInSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteInSubscriptionSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "DeleteInSubscription", resp, "Failure sending request") + return + } + + result, err = client.DeleteInSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "DeleteInSubscription", resp, "Failure responding to request") + } + + return +} + +// DeleteInSubscriptionPreparer prepares the DeleteInSubscription request. +func (client AssessmentsMetadataClient) DeleteInSubscriptionPreparer(ctx context.Context, assessmentMetadataName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentMetadataName": autorest.Encode("path", assessmentMetadataName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteInSubscriptionSender sends the DeleteInSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataClient) DeleteInSubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteInSubscriptionResponder handles the response to the DeleteInSubscription request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) DeleteInSubscriptionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get metadata information on an assessment type +// Parameters: +// assessmentMetadataName - the Assessment Key - Unique key for the assessment type +func (client AssessmentsMetadataClient) Get(ctx context.Context, assessmentMetadataName string) (result AssessmentMetadata, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, assessmentMetadataName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AssessmentsMetadataClient) GetPreparer(ctx context.Context, assessmentMetadataName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentMetadataName": autorest.Encode("path", assessmentMetadataName), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) GetResponder(resp *http.Response) (result AssessmentMetadata, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetInSubscription get metadata information on an assessment type in a specific subscription +// Parameters: +// assessmentMetadataName - the Assessment Key - Unique key for the assessment type +func (client AssessmentsMetadataClient) GetInSubscription(ctx context.Context, assessmentMetadataName string) (result AssessmentMetadata, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.GetInSubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AssessmentsMetadataClient", "GetInSubscription", err.Error()) + } + + req, err := client.GetInSubscriptionPreparer(ctx, assessmentMetadataName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "GetInSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.GetInSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "GetInSubscription", resp, "Failure sending request") + return + } + + result, err = client.GetInSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "GetInSubscription", resp, "Failure responding to request") + } + + return +} + +// GetInSubscriptionPreparer prepares the GetInSubscription request. +func (client AssessmentsMetadataClient) GetInSubscriptionPreparer(ctx context.Context, assessmentMetadataName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentMetadataName": autorest.Encode("path", assessmentMetadataName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetInSubscriptionSender sends the GetInSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataClient) GetInSubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetInSubscriptionResponder handles the response to the GetInSubscription request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) GetInSubscriptionResponder(resp *http.Response) (result AssessmentMetadata, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get metadata information on all assessment types +func (client AssessmentsMetadataClient) List(ctx context.Context) (result AssessmentMetadataListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.List") + defer func() { + sc := -1 + if result.aml.Response.Response != nil { + sc = result.aml.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.aml.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", resp, "Failure sending request") + return + } + + result.aml, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "List", resp, "Failure responding to request") + } + if result.aml.hasNextLink() && result.aml.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client AssessmentsMetadataClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Security/assessmentMetadata"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) ListResponder(resp *http.Response) (result AssessmentMetadataList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AssessmentsMetadataClient) listNextResults(ctx context.Context, lastResults AssessmentMetadataList) (result AssessmentMetadataList, err error) { + req, err := lastResults.assessmentMetadataListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AssessmentsMetadataClient) ListComplete(ctx context.Context) (result AssessmentMetadataListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListBySubscription get metadata information on all assessment types in a specific subscription +func (client AssessmentsMetadataClient) ListBySubscription(ctx context.Context) (result AssessmentMetadataListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.ListBySubscription") + defer func() { + sc := -1 + if result.aml.Response.Response != nil { + sc = result.aml.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AssessmentsMetadataClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.aml.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.aml, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "ListBySubscription", resp, "Failure responding to request") + } + if result.aml.hasNextLink() && result.aml.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client AssessmentsMetadataClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client AssessmentsMetadataClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client AssessmentsMetadataClient) ListBySubscriptionResponder(resp *http.Response) (result AssessmentMetadataList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client AssessmentsMetadataClient) listBySubscriptionNextResults(ctx context.Context, lastResults AssessmentMetadataList) (result AssessmentMetadataList, err error) { + req, err := lastResults.assessmentMetadataListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AssessmentsMetadataClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client AssessmentsMetadataClient) ListBySubscriptionComplete(ctx context.Context) (result AssessmentMetadataListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentsMetadataClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/automations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/automations.go new file mode 100644 index 0000000000000..106e5907b9b91 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/automations.go @@ -0,0 +1,638 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AutomationsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AutomationsClient struct { + BaseClient +} + +// NewAutomationsClient creates an instance of the AutomationsClient client. +func NewAutomationsClient(subscriptionID string, ascLocation string) AutomationsClient { + return NewAutomationsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAutomationsClientWithBaseURI creates an instance of the AutomationsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAutomationsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AutomationsClient { + return AutomationsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// CreateOrUpdate creates or updates a security automation. If a security automation is already created and a +// subsequent request is issued for the same automation id, then it will be updated. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// automationName - the security automation name. +// automation - the security automation resource +func (client AutomationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationName string, automation Automation) (result Automation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutomationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AutomationsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationName, automation) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AutomationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationName string, automation Automation) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationName": autorest.Encode("path", automationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}", pathParameters), + autorest.WithJSON(automation), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AutomationsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AutomationsClient) CreateOrUpdateResponder(resp *http.Response) (result Automation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a security automation. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// automationName - the security automation name. +func (client AutomationsClient) Delete(ctx context.Context, resourceGroupName string, automationName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutomationsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AutomationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, automationName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AutomationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationName": autorest.Encode("path", automationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AutomationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AutomationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieves information about the model of a security automation. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// automationName - the security automation name. +func (client AutomationsClient) Get(ctx context.Context, resourceGroupName string, automationName string) (result Automation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutomationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AutomationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, automationName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AutomationsClient) GetPreparer(ctx context.Context, resourceGroupName string, automationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationName": autorest.Encode("path", automationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AutomationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AutomationsClient) GetResponder(resp *http.Response) (result Automation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all the security automations in the specified subscription. Use the 'nextLink' property in the response +// to get the next page of security automations for the specified subscription. +func (client AutomationsClient) List(ctx context.Context) (result AutomationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutomationsClient.List") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AutomationsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "List", resp, "Failure sending request") + return + } + + result.al, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "List", resp, "Failure responding to request") + } + if result.al.hasNextLink() && result.al.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client AutomationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/automations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AutomationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AutomationsClient) ListResponder(resp *http.Response) (result AutomationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AutomationsClient) listNextResults(ctx context.Context, lastResults AutomationList) (result AutomationList, err error) { + req, err := lastResults.automationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AutomationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AutomationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AutomationsClient) ListComplete(ctx context.Context) (result AutomationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutomationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup lists all the security automations in the specified resource group. Use the 'nextLink' property +// in the response to get the next page of security automations for the specified resource group. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client AutomationsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AutomationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutomationsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AutomationsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.al, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.al.hasNextLink() && result.al.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AutomationsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AutomationsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AutomationsClient) ListByResourceGroupResponder(resp *http.Response) (result AutomationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client AutomationsClient) listByResourceGroupNextResults(ctx context.Context, lastResults AutomationList) (result AutomationList, err error) { + req, err := lastResults.automationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AutomationsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AutomationsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client AutomationsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AutomationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutomationsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Validate validates the security automation model before create or update. Any validation errors are returned to the +// client. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// automationName - the security automation name. +// automation - the security automation resource +func (client AutomationsClient) Validate(ctx context.Context, resourceGroupName string, automationName string, automation Automation) (result AutomationValidationStatus, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutomationsClient.Validate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AutomationsClient", "Validate", err.Error()) + } + + req, err := client.ValidatePreparer(ctx, resourceGroupName, automationName, automation) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "Validate", nil, "Failure preparing request") + return + } + + resp, err := client.ValidateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "Validate", resp, "Failure sending request") + return + } + + result, err = client.ValidateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutomationsClient", "Validate", resp, "Failure responding to request") + } + + return +} + +// ValidatePreparer prepares the Validate request. +func (client AutomationsClient) ValidatePreparer(ctx context.Context, resourceGroupName string, automationName string, automation Automation) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "automationName": autorest.Encode("path", automationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}/validate", pathParameters), + autorest.WithJSON(automation), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ValidateSender sends the Validate request. The method will close the +// http.Response Body if it receives an error. +func (client AutomationsClient) ValidateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ValidateResponder handles the response to the Validate request. The method always +// closes the http.Response Body. +func (client AutomationsClient) ValidateResponder(resp *http.Response) (result AutomationValidationStatus, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/autoprovisioningsettings.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/autoprovisioningsettings.go new file mode 100644 index 0000000000000..f9467280720bf --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/autoprovisioningsettings.go @@ -0,0 +1,322 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AutoProvisioningSettingsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type AutoProvisioningSettingsClient struct { + BaseClient +} + +// NewAutoProvisioningSettingsClient creates an instance of the AutoProvisioningSettingsClient client. +func NewAutoProvisioningSettingsClient(subscriptionID string, ascLocation string) AutoProvisioningSettingsClient { + return NewAutoProvisioningSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewAutoProvisioningSettingsClientWithBaseURI creates an instance of the AutoProvisioningSettingsClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewAutoProvisioningSettingsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) AutoProvisioningSettingsClient { + return AutoProvisioningSettingsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Create details of a specific setting +// Parameters: +// settingName - auto provisioning setting key +// setting - auto provisioning setting key +func (client AutoProvisioningSettingsClient) Create(ctx context.Context, settingName string, setting AutoProvisioningSetting) (result AutoProvisioningSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoProvisioningSettingsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AutoProvisioningSettingsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, settingName, setting) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client AutoProvisioningSettingsClient) CreatePreparer(ctx context.Context, settingName string, setting AutoProvisioningSetting) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "settingName": autorest.Encode("path", settingName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}", pathParameters), + autorest.WithJSON(setting), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client AutoProvisioningSettingsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client AutoProvisioningSettingsClient) CreateResponder(resp *http.Response) (result AutoProvisioningSetting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get details of a specific setting +// Parameters: +// settingName - auto provisioning setting key +func (client AutoProvisioningSettingsClient) Get(ctx context.Context, settingName string) (result AutoProvisioningSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoProvisioningSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AutoProvisioningSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, settingName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AutoProvisioningSettingsClient) GetPreparer(ctx context.Context, settingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "settingName": autorest.Encode("path", settingName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AutoProvisioningSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AutoProvisioningSettingsClient) GetResponder(resp *http.Response) (result AutoProvisioningSetting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List exposes the auto provisioning settings of the subscriptions +func (client AutoProvisioningSettingsClient) List(ctx context.Context) (result AutoProvisioningSettingListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoProvisioningSettingsClient.List") + defer func() { + sc := -1 + if result.apsl.Response.Response != nil { + sc = result.apsl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.AutoProvisioningSettingsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.apsl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "List", resp, "Failure sending request") + return + } + + result.apsl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "List", resp, "Failure responding to request") + } + if result.apsl.hasNextLink() && result.apsl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client AutoProvisioningSettingsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AutoProvisioningSettingsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AutoProvisioningSettingsClient) ListResponder(resp *http.Response) (result AutoProvisioningSettingList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AutoProvisioningSettingsClient) listNextResults(ctx context.Context, lastResults AutoProvisioningSettingList) (result AutoProvisioningSettingList, err error) { + req, err := lastResults.autoProvisioningSettingListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AutoProvisioningSettingsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AutoProvisioningSettingsClient) ListComplete(ctx context.Context) (result AutoProvisioningSettingListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoProvisioningSettingsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/client.go new file mode 100644 index 0000000000000..ca26dee802e72 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/client.go @@ -0,0 +1,54 @@ +// Package security implements the Azure ARM Security service API version . +// +// API spec for Microsoft.Security (Azure Security Center) resource provider +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Security + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Security. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string + AscLocation string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string, ascLocation string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string, ascLocation string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + AscLocation: ascLocation, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/complianceresults.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/complianceresults.go new file mode 100644 index 0000000000000..8415b71043e32 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/complianceresults.go @@ -0,0 +1,231 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ComplianceResultsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type ComplianceResultsClient struct { + BaseClient +} + +// NewComplianceResultsClient creates an instance of the ComplianceResultsClient client. +func NewComplianceResultsClient(subscriptionID string, ascLocation string) ComplianceResultsClient { + return NewComplianceResultsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewComplianceResultsClientWithBaseURI creates an instance of the ComplianceResultsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewComplianceResultsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) ComplianceResultsClient { + return ComplianceResultsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get security Compliance Result +// Parameters: +// resourceID - the identifier of the resource. +// complianceResultName - name of the desired assessment compliance result +func (client ComplianceResultsClient) Get(ctx context.Context, resourceID string, complianceResultName string) (result ComplianceResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComplianceResultsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceID, complianceResultName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ComplianceResultsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ComplianceResultsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ComplianceResultsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ComplianceResultsClient) GetPreparer(ctx context.Context, resourceID string, complianceResultName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "complianceResultName": autorest.Encode("path", complianceResultName), + "resourceId": resourceID, + } + + const APIVersion = "2017-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/complianceResults/{complianceResultName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ComplianceResultsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ComplianceResultsClient) GetResponder(resp *http.Response) (result ComplianceResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List security compliance results in the subscription +// Parameters: +// scope - scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or +// management group (/providers/Microsoft.Management/managementGroups/mgName). +func (client ComplianceResultsClient) List(ctx context.Context, scope string) (result ComplianceResultListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComplianceResultsClient.List") + defer func() { + sc := -1 + if result.crl.Response.Response != nil { + sc = result.crl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ComplianceResultsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.crl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ComplianceResultsClient", "List", resp, "Failure sending request") + return + } + + result.crl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ComplianceResultsClient", "List", resp, "Failure responding to request") + } + if result.crl.hasNextLink() && result.crl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client ComplianceResultsClient) ListPreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2017-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Security/complianceResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ComplianceResultsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ComplianceResultsClient) ListResponder(resp *http.Response) (result ComplianceResultList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ComplianceResultsClient) listNextResults(ctx context.Context, lastResults ComplianceResultList) (result ComplianceResultList, err error) { + req, err := lastResults.complianceResultListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.ComplianceResultsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.ComplianceResultsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ComplianceResultsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ComplianceResultsClient) ListComplete(ctx context.Context, scope string) (result ComplianceResultListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComplianceResultsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, scope) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/compliances.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/compliances.go new file mode 100644 index 0000000000000..dbce5f7be95f6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/compliances.go @@ -0,0 +1,231 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CompliancesClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type CompliancesClient struct { + BaseClient +} + +// NewCompliancesClient creates an instance of the CompliancesClient client. +func NewCompliancesClient(subscriptionID string, ascLocation string) CompliancesClient { + return NewCompliancesClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewCompliancesClientWithBaseURI creates an instance of the CompliancesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCompliancesClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) CompliancesClient { + return CompliancesClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get details of a specific Compliance. +// Parameters: +// scope - scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or +// management group (/providers/Microsoft.Management/managementGroups/mgName). +// complianceName - name of the Compliance +func (client CompliancesClient) Get(ctx context.Context, scope string, complianceName string) (result Compliance, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CompliancesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, scope, complianceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.CompliancesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.CompliancesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.CompliancesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CompliancesClient) GetPreparer(ctx context.Context, scope string, complianceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "complianceName": autorest.Encode("path", complianceName), + "scope": scope, + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Security/compliances/{complianceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client CompliancesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CompliancesClient) GetResponder(resp *http.Response) (result Compliance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List the Compliance scores of the specific management group. +// Parameters: +// scope - scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or +// management group (/providers/Microsoft.Management/managementGroups/mgName). +func (client CompliancesClient) List(ctx context.Context, scope string) (result ComplianceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CompliancesClient.List") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "security.CompliancesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.CompliancesClient", "List", resp, "Failure sending request") + return + } + + result.cl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.CompliancesClient", "List", resp, "Failure responding to request") + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client CompliancesClient) ListPreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Security/compliances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client CompliancesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client CompliancesClient) ListResponder(resp *http.Response) (result ComplianceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client CompliancesClient) listNextResults(ctx context.Context, lastResults ComplianceList) (result ComplianceList, err error) { + req, err := lastResults.complianceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.CompliancesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.CompliancesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.CompliancesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client CompliancesClient) ListComplete(ctx context.Context, scope string) (result ComplianceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CompliancesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, scope) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/connectors.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/connectors.go new file mode 100644 index 0000000000000..283167416f160 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/connectors.go @@ -0,0 +1,400 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ConnectorsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type ConnectorsClient struct { + BaseClient +} + +// NewConnectorsClient creates an instance of the ConnectorsClient client. +func NewConnectorsClient(subscriptionID string, ascLocation string) ConnectorsClient { + return NewConnectorsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewConnectorsClientWithBaseURI creates an instance of the ConnectorsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewConnectorsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) ConnectorsClient { + return ConnectorsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// CreateOrUpdate create a cloud account connector or update an existing one. Connect to your AWS cloud account using +// either account credentials or role-based authentication. +// Parameters: +// connectorName - name of the cloud account connector +// connectorSetting - settings for the cloud account connector +func (client ConnectorsClient) CreateOrUpdate(ctx context.Context, connectorName string, connectorSetting ConnectorSetting) (result ConnectorSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ConnectorsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, connectorName, connectorSetting) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConnectorsClient) CreateOrUpdatePreparer(ctx context.Context, connectorName string, connectorSetting ConnectorSetting) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectorName": autorest.Encode("path", connectorName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}", pathParameters), + autorest.WithJSON(connectorSetting), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectorsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ConnectorsClient) CreateOrUpdateResponder(resp *http.Response) (result ConnectorSetting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a cloud account connector from a subscription +// Parameters: +// connectorName - name of the cloud account connector +func (client ConnectorsClient) Delete(ctx context.Context, connectorName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectorsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ConnectorsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, connectorName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectorsClient) DeletePreparer(ctx context.Context, connectorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectorName": autorest.Encode("path", connectorName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectorsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConnectorsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get details of a specific cloud account connector +// Parameters: +// connectorName - name of the cloud account connector +func (client ConnectorsClient) Get(ctx context.Context, connectorName string) (result ConnectorSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ConnectorsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, connectorName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectorsClient) GetPreparer(ctx context.Context, connectorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectorName": autorest.Encode("path", connectorName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConnectorsClient) GetResponder(resp *http.Response) (result ConnectorSetting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List cloud accounts connectors of a subscription +func (client ConnectorsClient) List(ctx context.Context) (result ConnectorSettingListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectorsClient.List") + defer func() { + sc := -1 + if result.csl.Response.Response != nil { + sc = result.csl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ConnectorsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.csl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "List", resp, "Failure sending request") + return + } + + result.csl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "List", resp, "Failure responding to request") + } + if result.csl.hasNextLink() && result.csl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client ConnectorsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectorsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ConnectorsClient) ListResponder(resp *http.Response) (result ConnectorSettingList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ConnectorsClient) listNextResults(ctx context.Context, lastResults ConnectorSettingList) (result ConnectorSettingList, err error) { + req, err := lastResults.connectorSettingListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.ConnectorsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.ConnectorsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ConnectorsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConnectorsClient) ListComplete(ctx context.Context) (result ConnectorSettingListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectorsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/contacts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/contacts.go new file mode 100644 index 0000000000000..3bacee1cf6311 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/contacts.go @@ -0,0 +1,484 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ContactsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type ContactsClient struct { + BaseClient +} + +// NewContactsClient creates an instance of the ContactsClient client. +func NewContactsClient(subscriptionID string, ascLocation string) ContactsClient { + return NewContactsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewContactsClientWithBaseURI creates an instance of the ContactsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewContactsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) ContactsClient { + return ContactsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Create security contact configurations for the subscription +// Parameters: +// securityContactName - name of the security contact object +// securityContact - security contact object +func (client ContactsClient) Create(ctx context.Context, securityContactName string, securityContact Contact) (result Contact, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContactsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: securityContact, + Constraints: []validation.Constraint{{Target: "securityContact.ContactProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "securityContact.ContactProperties.Email", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("security.ContactsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, securityContactName, securityContact) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ContactsClient) CreatePreparer(ctx context.Context, securityContactName string, securityContact Contact) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "securityContactName": autorest.Encode("path", securityContactName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", pathParameters), + autorest.WithJSON(securityContact), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ContactsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ContactsClient) CreateResponder(resp *http.Response) (result Contact, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete security contact configurations for the subscription +// Parameters: +// securityContactName - name of the security contact object +func (client ContactsClient) Delete(ctx context.Context, securityContactName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContactsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ContactsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, securityContactName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ContactsClient) DeletePreparer(ctx context.Context, securityContactName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "securityContactName": autorest.Encode("path", securityContactName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ContactsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ContactsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get security contact configurations for the subscription +// Parameters: +// securityContactName - name of the security contact object +func (client ContactsClient) Get(ctx context.Context, securityContactName string) (result Contact, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContactsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ContactsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, securityContactName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ContactsClient) GetPreparer(ctx context.Context, securityContactName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "securityContactName": autorest.Encode("path", securityContactName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ContactsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ContactsClient) GetResponder(resp *http.Response) (result Contact, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List security contact configurations for the subscription +func (client ContactsClient) List(ctx context.Context) (result ContactListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContactsClient.List") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ContactsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ContactsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ContactsClient", "List", resp, "Failure sending request") + return + } + + result.cl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ContactsClient", "List", resp, "Failure responding to request") + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client ContactsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ContactsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ContactsClient) ListResponder(resp *http.Response) (result ContactList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ContactsClient) listNextResults(ctx context.Context, lastResults ContactList) (result ContactList, err error) { + req, err := lastResults.contactListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.ContactsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.ContactsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ContactsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ContactsClient) ListComplete(ctx context.Context) (result ContactListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContactsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// Update security contact configurations for the subscription +// Parameters: +// securityContactName - name of the security contact object +// securityContact - security contact object +func (client ContactsClient) Update(ctx context.Context, securityContactName string, securityContact Contact) (result Contact, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContactsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ContactsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, securityContactName, securityContact) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ContactsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ContactsClient) UpdatePreparer(ctx context.Context, securityContactName string, securityContact Contact) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "securityContactName": autorest.Encode("path", securityContactName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", pathParameters), + autorest.WithJSON(securityContact), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ContactsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ContactsClient) UpdateResponder(resp *http.Response) (result Contact, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/devicesecuritygroups.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/devicesecuritygroups.go new file mode 100644 index 0000000000000..8d20b62e31605 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/devicesecuritygroups.go @@ -0,0 +1,383 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DeviceSecurityGroupsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type DeviceSecurityGroupsClient struct { + BaseClient +} + +// NewDeviceSecurityGroupsClient creates an instance of the DeviceSecurityGroupsClient client. +func NewDeviceSecurityGroupsClient(subscriptionID string, ascLocation string) DeviceSecurityGroupsClient { + return NewDeviceSecurityGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewDeviceSecurityGroupsClientWithBaseURI creates an instance of the DeviceSecurityGroupsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDeviceSecurityGroupsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) DeviceSecurityGroupsClient { + return DeviceSecurityGroupsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// CreateOrUpdate use this method to creates or updates the device security group on a specified IoT Hub resource. +// Parameters: +// resourceID - the identifier of the resource. +// deviceSecurityGroupName - the name of the device security group. Note that the name of the device security +// group is case insensitive. +// deviceSecurityGroup - security group object. +func (client DeviceSecurityGroupsClient) CreateOrUpdate(ctx context.Context, resourceID string, deviceSecurityGroupName string, deviceSecurityGroup DeviceSecurityGroup) (result DeviceSecurityGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSecurityGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceID, deviceSecurityGroupName, deviceSecurityGroup) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DeviceSecurityGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceID string, deviceSecurityGroupName string, deviceSecurityGroup DeviceSecurityGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceSecurityGroupName": autorest.Encode("path", deviceSecurityGroupName), + "resourceId": resourceID, + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}", pathParameters), + autorest.WithJSON(deviceSecurityGroup), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSecurityGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DeviceSecurityGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result DeviceSecurityGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete user this method to deletes the device security group. +// Parameters: +// resourceID - the identifier of the resource. +// deviceSecurityGroupName - the name of the device security group. Note that the name of the device security +// group is case insensitive. +func (client DeviceSecurityGroupsClient) Delete(ctx context.Context, resourceID string, deviceSecurityGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSecurityGroupsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceID, deviceSecurityGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DeviceSecurityGroupsClient) DeletePreparer(ctx context.Context, resourceID string, deviceSecurityGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceSecurityGroupName": autorest.Encode("path", deviceSecurityGroupName), + "resourceId": resourceID, + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSecurityGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DeviceSecurityGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get use this method to get the device security group for the specified IoT Hub resource. +// Parameters: +// resourceID - the identifier of the resource. +// deviceSecurityGroupName - the name of the device security group. Note that the name of the device security +// group is case insensitive. +func (client DeviceSecurityGroupsClient) Get(ctx context.Context, resourceID string, deviceSecurityGroupName string) (result DeviceSecurityGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSecurityGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceID, deviceSecurityGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DeviceSecurityGroupsClient) GetPreparer(ctx context.Context, resourceID string, deviceSecurityGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceSecurityGroupName": autorest.Encode("path", deviceSecurityGroupName), + "resourceId": resourceID, + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSecurityGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DeviceSecurityGroupsClient) GetResponder(resp *http.Response) (result DeviceSecurityGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List use this method get the list of device security groups for the specified IoT Hub resource. +// Parameters: +// resourceID - the identifier of the resource. +func (client DeviceSecurityGroupsClient) List(ctx context.Context, resourceID string) (result DeviceSecurityGroupListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSecurityGroupsClient.List") + defer func() { + sc := -1 + if result.dsgl.Response.Response != nil { + sc = result.dsgl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceID) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.dsgl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "List", resp, "Failure sending request") + return + } + + result.dsgl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "List", resp, "Failure responding to request") + } + if result.dsgl.hasNextLink() && result.dsgl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client DeviceSecurityGroupsClient) ListPreparer(ctx context.Context, resourceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceId": resourceID, + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSecurityGroupsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DeviceSecurityGroupsClient) ListResponder(resp *http.Response) (result DeviceSecurityGroupList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client DeviceSecurityGroupsClient) listNextResults(ctx context.Context, lastResults DeviceSecurityGroupList) (result DeviceSecurityGroupList, err error) { + req, err := lastResults.deviceSecurityGroupListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DeviceSecurityGroupsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client DeviceSecurityGroupsClient) ListComplete(ctx context.Context, resourceID string) (result DeviceSecurityGroupListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSecurityGroupsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceID) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/discoveredsecuritysolutions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/discoveredsecuritysolutions.go new file mode 100644 index 0000000000000..f199814657db1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/discoveredsecuritysolutions.go @@ -0,0 +1,366 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DiscoveredSecuritySolutionsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type DiscoveredSecuritySolutionsClient struct { + BaseClient +} + +// NewDiscoveredSecuritySolutionsClient creates an instance of the DiscoveredSecuritySolutionsClient client. +func NewDiscoveredSecuritySolutionsClient(subscriptionID string, ascLocation string) DiscoveredSecuritySolutionsClient { + return NewDiscoveredSecuritySolutionsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewDiscoveredSecuritySolutionsClientWithBaseURI creates an instance of the DiscoveredSecuritySolutionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewDiscoveredSecuritySolutionsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) DiscoveredSecuritySolutionsClient { + return DiscoveredSecuritySolutionsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get gets a specific discovered Security Solution. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// discoveredSecuritySolutionName - name of a discovered security solution. +func (client DiscoveredSecuritySolutionsClient) Get(ctx context.Context, resourceGroupName string, discoveredSecuritySolutionName string) (result DiscoveredSecuritySolution, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiscoveredSecuritySolutionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.DiscoveredSecuritySolutionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, discoveredSecuritySolutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DiscoveredSecuritySolutionsClient) GetPreparer(ctx context.Context, resourceGroupName string, discoveredSecuritySolutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "discoveredSecuritySolutionName": autorest.Encode("path", discoveredSecuritySolutionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions/{discoveredSecuritySolutionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DiscoveredSecuritySolutionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DiscoveredSecuritySolutionsClient) GetResponder(resp *http.Response) (result DiscoveredSecuritySolution, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of discovered Security Solutions for the subscription. +func (client DiscoveredSecuritySolutionsClient) List(ctx context.Context) (result DiscoveredSecuritySolutionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiscoveredSecuritySolutionsClient.List") + defer func() { + sc := -1 + if result.dssl.Response.Response != nil { + sc = result.dssl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.DiscoveredSecuritySolutionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.dssl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "List", resp, "Failure sending request") + return + } + + result.dssl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "List", resp, "Failure responding to request") + } + if result.dssl.hasNextLink() && result.dssl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client DiscoveredSecuritySolutionsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/discoveredSecuritySolutions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DiscoveredSecuritySolutionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DiscoveredSecuritySolutionsClient) ListResponder(resp *http.Response) (result DiscoveredSecuritySolutionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client DiscoveredSecuritySolutionsClient) listNextResults(ctx context.Context, lastResults DiscoveredSecuritySolutionList) (result DiscoveredSecuritySolutionList, err error) { + req, err := lastResults.discoveredSecuritySolutionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client DiscoveredSecuritySolutionsClient) ListComplete(ctx context.Context) (result DiscoveredSecuritySolutionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiscoveredSecuritySolutionsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByHomeRegion gets a list of discovered Security Solutions for the subscription and location. +func (client DiscoveredSecuritySolutionsClient) ListByHomeRegion(ctx context.Context) (result DiscoveredSecuritySolutionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiscoveredSecuritySolutionsClient.ListByHomeRegion") + defer func() { + sc := -1 + if result.dssl.Response.Response != nil { + sc = result.dssl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.DiscoveredSecuritySolutionsClient", "ListByHomeRegion", err.Error()) + } + + result.fn = client.listByHomeRegionNextResults + req, err := client.ListByHomeRegionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "ListByHomeRegion", nil, "Failure preparing request") + return + } + + resp, err := client.ListByHomeRegionSender(req) + if err != nil { + result.dssl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "ListByHomeRegion", resp, "Failure sending request") + return + } + + result.dssl, err = client.ListByHomeRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "ListByHomeRegion", resp, "Failure responding to request") + } + if result.dssl.hasNextLink() && result.dssl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByHomeRegionPreparer prepares the ListByHomeRegion request. +func (client DiscoveredSecuritySolutionsClient) ListByHomeRegionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByHomeRegionSender sends the ListByHomeRegion request. The method will close the +// http.Response Body if it receives an error. +func (client DiscoveredSecuritySolutionsClient) ListByHomeRegionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByHomeRegionResponder handles the response to the ListByHomeRegion request. The method always +// closes the http.Response Body. +func (client DiscoveredSecuritySolutionsClient) ListByHomeRegionResponder(resp *http.Response) (result DiscoveredSecuritySolutionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByHomeRegionNextResults retrieves the next set of results, if any. +func (client DiscoveredSecuritySolutionsClient) listByHomeRegionNextResults(ctx context.Context, lastResults DiscoveredSecuritySolutionList) (result DiscoveredSecuritySolutionList, err error) { + req, err := lastResults.discoveredSecuritySolutionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "listByHomeRegionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByHomeRegionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "listByHomeRegionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByHomeRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.DiscoveredSecuritySolutionsClient", "listByHomeRegionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByHomeRegionComplete enumerates all values, automatically crossing page boundaries as required. +func (client DiscoveredSecuritySolutionsClient) ListByHomeRegionComplete(ctx context.Context) (result DiscoveredSecuritySolutionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiscoveredSecuritySolutionsClient.ListByHomeRegion") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByHomeRegion(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/enums.go new file mode 100644 index 0000000000000..f5703d67f45cf --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/enums.go @@ -0,0 +1,1401 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AadConnectivityState enumerates the values for aad connectivity state. +type AadConnectivityState string + +const ( + // Connected ... + Connected AadConnectivityState = "Connected" + // Discovered ... + Discovered AadConnectivityState = "Discovered" + // NotLicensed ... + NotLicensed AadConnectivityState = "NotLicensed" +) + +// PossibleAadConnectivityStateValues returns an array of possible values for the AadConnectivityState const type. +func PossibleAadConnectivityStateValues() []AadConnectivityState { + return []AadConnectivityState{Connected, Discovered, NotLicensed} +} + +// Action enumerates the values for action. +type Action string + +const ( + // Add ... + Add Action = "Add" + // Recommended ... + Recommended Action = "Recommended" + // Remove ... + Remove Action = "Remove" +) + +// PossibleActionValues returns an array of possible values for the Action const type. +func PossibleActionValues() []Action { + return []Action{Add, Recommended, Remove} +} + +// ActionType enumerates the values for action type. +type ActionType string + +const ( + // ActionTypeAutomationAction ... + ActionTypeAutomationAction ActionType = "AutomationAction" + // ActionTypeEventHub ... + ActionTypeEventHub ActionType = "EventHub" + // ActionTypeLogicApp ... + ActionTypeLogicApp ActionType = "LogicApp" + // ActionTypeWorkspace ... + ActionTypeWorkspace ActionType = "Workspace" +) + +// PossibleActionTypeValues returns an array of possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ActionTypeAutomationAction, ActionTypeEventHub, ActionTypeLogicApp, ActionTypeWorkspace} +} + +// AlertIntent enumerates the values for alert intent. +type AlertIntent string + +const ( + // Collection ... + Collection AlertIntent = "Collection" + // CommandAndControl ... + CommandAndControl AlertIntent = "CommandAndControl" + // CredentialAccess ... + CredentialAccess AlertIntent = "CredentialAccess" + // DefenseEvasion ... + DefenseEvasion AlertIntent = "DefenseEvasion" + // Discovery ... + Discovery AlertIntent = "Discovery" + // Execution ... + Execution AlertIntent = "Execution" + // Exfiltration ... + Exfiltration AlertIntent = "Exfiltration" + // Exploitation ... + Exploitation AlertIntent = "Exploitation" + // Impact ... + Impact AlertIntent = "Impact" + // InitialAccess ... + InitialAccess AlertIntent = "InitialAccess" + // LateralMovement ... + LateralMovement AlertIntent = "LateralMovement" + // Persistence ... + Persistence AlertIntent = "Persistence" + // PreAttack ... + PreAttack AlertIntent = "PreAttack" + // PrivilegeEscalation ... + PrivilegeEscalation AlertIntent = "PrivilegeEscalation" + // Probing ... + Probing AlertIntent = "Probing" + // Unknown ... + Unknown AlertIntent = "Unknown" +) + +// PossibleAlertIntentValues returns an array of possible values for the AlertIntent const type. +func PossibleAlertIntentValues() []AlertIntent { + return []AlertIntent{Collection, CommandAndControl, CredentialAccess, DefenseEvasion, Discovery, Execution, Exfiltration, Exploitation, Impact, InitialAccess, LateralMovement, Persistence, PreAttack, PrivilegeEscalation, Probing, Unknown} +} + +// AlertNotifications enumerates the values for alert notifications. +type AlertNotifications string + +const ( + // Off Don't get notifications on new alerts + Off AlertNotifications = "Off" + // On Get notifications on new alerts + On AlertNotifications = "On" +) + +// PossibleAlertNotificationsValues returns an array of possible values for the AlertNotifications const type. +func PossibleAlertNotificationsValues() []AlertNotifications { + return []AlertNotifications{Off, On} +} + +// AlertSeverity enumerates the values for alert severity. +type AlertSeverity string + +const ( + // High ... + High AlertSeverity = "High" + // Informational ... + Informational AlertSeverity = "Informational" + // Low ... + Low AlertSeverity = "Low" + // Medium ... + Medium AlertSeverity = "Medium" +) + +// PossibleAlertSeverityValues returns an array of possible values for the AlertSeverity const type. +func PossibleAlertSeverityValues() []AlertSeverity { + return []AlertSeverity{High, Informational, Low, Medium} +} + +// AlertsToAdmins enumerates the values for alerts to admins. +type AlertsToAdmins string + +const ( + // AlertsToAdminsOff Don't send notification on new alerts to the subscription's admins + AlertsToAdminsOff AlertsToAdmins = "Off" + // AlertsToAdminsOn Send notification on new alerts to the subscription's admins + AlertsToAdminsOn AlertsToAdmins = "On" +) + +// PossibleAlertsToAdminsValues returns an array of possible values for the AlertsToAdmins const type. +func PossibleAlertsToAdminsValues() []AlertsToAdmins { + return []AlertsToAdmins{AlertsToAdminsOff, AlertsToAdminsOn} +} + +// AssessedResourceType enumerates the values for assessed resource type. +type AssessedResourceType string + +const ( + // AssessedResourceTypeAdditionalData ... + AssessedResourceTypeAdditionalData AssessedResourceType = "AdditionalData" + // AssessedResourceTypeContainerRegistryVulnerability ... + AssessedResourceTypeContainerRegistryVulnerability AssessedResourceType = "ContainerRegistryVulnerability" + // AssessedResourceTypeServerVulnerabilityAssessment ... + AssessedResourceTypeServerVulnerabilityAssessment AssessedResourceType = "ServerVulnerabilityAssessment" + // AssessedResourceTypeSQLServerVulnerability ... + AssessedResourceTypeSQLServerVulnerability AssessedResourceType = "SqlServerVulnerability" +) + +// PossibleAssessedResourceTypeValues returns an array of possible values for the AssessedResourceType const type. +func PossibleAssessedResourceTypeValues() []AssessedResourceType { + return []AssessedResourceType{AssessedResourceTypeAdditionalData, AssessedResourceTypeContainerRegistryVulnerability, AssessedResourceTypeServerVulnerabilityAssessment, AssessedResourceTypeSQLServerVulnerability} +} + +// AssessmentStatusCode enumerates the values for assessment status code. +type AssessmentStatusCode string + +const ( + // Healthy The resource is healthy + Healthy AssessmentStatusCode = "Healthy" + // NotApplicable Assessment for this resource did not happen + NotApplicable AssessmentStatusCode = "NotApplicable" + // Unhealthy The resource has a security issue that needs to be addressed + Unhealthy AssessmentStatusCode = "Unhealthy" +) + +// PossibleAssessmentStatusCodeValues returns an array of possible values for the AssessmentStatusCode const type. +func PossibleAssessmentStatusCodeValues() []AssessmentStatusCode { + return []AssessmentStatusCode{Healthy, NotApplicable, Unhealthy} +} + +// AssessmentType enumerates the values for assessment type. +type AssessmentType string + +const ( + // BuiltIn Azure Security Center managed assessments + BuiltIn AssessmentType = "BuiltIn" + // CustomerManaged User assessments pushed directly by the user or other third party to Azure Security + // Center + CustomerManaged AssessmentType = "CustomerManaged" + // CustomPolicy User defined policies that are automatically ingested from Azure Policy to Azure Security + // Center + CustomPolicy AssessmentType = "CustomPolicy" + // VerifiedPartner An assessment that was created by a verified 3rd party if the user connected it to ASC + VerifiedPartner AssessmentType = "VerifiedPartner" +) + +// PossibleAssessmentTypeValues returns an array of possible values for the AssessmentType const type. +func PossibleAssessmentTypeValues() []AssessmentType { + return []AssessmentType{BuiltIn, CustomerManaged, CustomPolicy, VerifiedPartner} +} + +// AuthenticationProvisioningState enumerates the values for authentication provisioning state. +type AuthenticationProvisioningState string + +const ( + // Expired the connection is expired + Expired AuthenticationProvisioningState = "Expired" + // IncorrectPolicy Incorrect policy of the connector + IncorrectPolicy AuthenticationProvisioningState = "IncorrectPolicy" + // Invalid Invalid connector + Invalid AuthenticationProvisioningState = "Invalid" + // Valid Valid connector + Valid AuthenticationProvisioningState = "Valid" +) + +// PossibleAuthenticationProvisioningStateValues returns an array of possible values for the AuthenticationProvisioningState const type. +func PossibleAuthenticationProvisioningStateValues() []AuthenticationProvisioningState { + return []AuthenticationProvisioningState{Expired, IncorrectPolicy, Invalid, Valid} +} + +// AuthenticationType enumerates the values for authentication type. +type AuthenticationType string + +const ( + // AuthenticationTypeAuthenticationDetailsProperties ... + AuthenticationTypeAuthenticationDetailsProperties AuthenticationType = "AuthenticationDetailsProperties" + // AuthenticationTypeAwsAssumeRole ... + AuthenticationTypeAwsAssumeRole AuthenticationType = "awsAssumeRole" + // AuthenticationTypeAwsCreds ... + AuthenticationTypeAwsCreds AuthenticationType = "awsCreds" + // AuthenticationTypeGcpCredentials ... + AuthenticationTypeGcpCredentials AuthenticationType = "gcpCredentials" +) + +// PossibleAuthenticationTypeValues returns an array of possible values for the AuthenticationType const type. +func PossibleAuthenticationTypeValues() []AuthenticationType { + return []AuthenticationType{AuthenticationTypeAuthenticationDetailsProperties, AuthenticationTypeAwsAssumeRole, AuthenticationTypeAwsCreds, AuthenticationTypeGcpCredentials} +} + +// AutoProvision enumerates the values for auto provision. +type AutoProvision string + +const ( + // AutoProvisionOff Do not install security agent on the VMs automatically + AutoProvisionOff AutoProvision = "Off" + // AutoProvisionOn Install missing security agent on VMs automatically + AutoProvisionOn AutoProvision = "On" +) + +// PossibleAutoProvisionValues returns an array of possible values for the AutoProvision const type. +func PossibleAutoProvisionValues() []AutoProvision { + return []AutoProvision{AutoProvisionOff, AutoProvisionOn} +} + +// Category enumerates the values for category. +type Category string + +const ( + // Compute ... + Compute Category = "Compute" + // Data ... + Data Category = "Data" + // IdentityAndAccess ... + IdentityAndAccess Category = "IdentityAndAccess" + // IoT ... + IoT Category = "IoT" + // Networking ... + Networking Category = "Networking" +) + +// PossibleCategoryValues returns an array of possible values for the Category const type. +func PossibleCategoryValues() []Category { + return []Category{Compute, Data, IdentityAndAccess, IoT, Networking} +} + +// ConfigurationStatus enumerates the values for configuration status. +type ConfigurationStatus string + +const ( + // Configured ... + Configured ConfigurationStatus = "Configured" + // Failed ... + Failed ConfigurationStatus = "Failed" + // InProgress ... + InProgress ConfigurationStatus = "InProgress" + // NoStatus ... + NoStatus ConfigurationStatus = "NoStatus" + // NotConfigured ... + NotConfigured ConfigurationStatus = "NotConfigured" +) + +// PossibleConfigurationStatusValues returns an array of possible values for the ConfigurationStatus const type. +func PossibleConfigurationStatusValues() []ConfigurationStatus { + return []ConfigurationStatus{Configured, Failed, InProgress, NoStatus, NotConfigured} +} + +// ConfigurationStatus1 enumerates the values for configuration status 1. +type ConfigurationStatus1 string + +const ( + // ConfigurationStatus1Configured ... + ConfigurationStatus1Configured ConfigurationStatus1 = "Configured" + // ConfigurationStatus1Failed ... + ConfigurationStatus1Failed ConfigurationStatus1 = "Failed" + // ConfigurationStatus1InProgress ... + ConfigurationStatus1InProgress ConfigurationStatus1 = "InProgress" + // ConfigurationStatus1NoStatus ... + ConfigurationStatus1NoStatus ConfigurationStatus1 = "NoStatus" + // ConfigurationStatus1NotConfigured ... + ConfigurationStatus1NotConfigured ConfigurationStatus1 = "NotConfigured" +) + +// PossibleConfigurationStatus1Values returns an array of possible values for the ConfigurationStatus1 const type. +func PossibleConfigurationStatus1Values() []ConfigurationStatus1 { + return []ConfigurationStatus1{ConfigurationStatus1Configured, ConfigurationStatus1Failed, ConfigurationStatus1InProgress, ConfigurationStatus1NoStatus, ConfigurationStatus1NotConfigured} +} + +// ConfigurationStatus2 enumerates the values for configuration status 2. +type ConfigurationStatus2 string + +const ( + // ConfigurationStatus2Configured ... + ConfigurationStatus2Configured ConfigurationStatus2 = "Configured" + // ConfigurationStatus2Failed ... + ConfigurationStatus2Failed ConfigurationStatus2 = "Failed" + // ConfigurationStatus2InProgress ... + ConfigurationStatus2InProgress ConfigurationStatus2 = "InProgress" + // ConfigurationStatus2NoStatus ... + ConfigurationStatus2NoStatus ConfigurationStatus2 = "NoStatus" + // ConfigurationStatus2NotConfigured ... + ConfigurationStatus2NotConfigured ConfigurationStatus2 = "NotConfigured" +) + +// PossibleConfigurationStatus2Values returns an array of possible values for the ConfigurationStatus2 const type. +func PossibleConfigurationStatus2Values() []ConfigurationStatus2 { + return []ConfigurationStatus2{ConfigurationStatus2Configured, ConfigurationStatus2Failed, ConfigurationStatus2InProgress, ConfigurationStatus2NoStatus, ConfigurationStatus2NotConfigured} +} + +// ConnectionType enumerates the values for connection type. +type ConnectionType string + +const ( + // External ... + External ConnectionType = "External" + // Internal ... + Internal ConnectionType = "Internal" +) + +// PossibleConnectionTypeValues returns an array of possible values for the ConnectionType const type. +func PossibleConnectionTypeValues() []ConnectionType { + return []ConnectionType{External, Internal} +} + +// ControlType enumerates the values for control type. +type ControlType string + +const ( + // ControlTypeBuiltIn Azure Security Center managed assessments + ControlTypeBuiltIn ControlType = "BuiltIn" + // ControlTypeCustom Non Azure Security Center managed assessments + ControlTypeCustom ControlType = "Custom" +) + +// PossibleControlTypeValues returns an array of possible values for the ControlType const type. +func PossibleControlTypeValues() []ControlType { + return []ControlType{ControlTypeBuiltIn, ControlTypeCustom} +} + +// DataSource enumerates the values for data source. +type DataSource string + +const ( + // TwinData Devices twin data + TwinData DataSource = "TwinData" +) + +// PossibleDataSourceValues returns an array of possible values for the DataSource const type. +func PossibleDataSourceValues() []DataSource { + return []DataSource{TwinData} +} + +// Direction enumerates the values for direction. +type Direction string + +const ( + // Inbound ... + Inbound Direction = "Inbound" + // Outbound ... + Outbound Direction = "Outbound" +) + +// PossibleDirectionValues returns an array of possible values for the Direction const type. +func PossibleDirectionValues() []Direction { + return []Direction{Inbound, Outbound} +} + +// EnforcementMode enumerates the values for enforcement mode. +type EnforcementMode string + +const ( + // Audit ... + Audit EnforcementMode = "Audit" + // Enforce ... + Enforce EnforcementMode = "Enforce" + // None ... + None EnforcementMode = "None" +) + +// PossibleEnforcementModeValues returns an array of possible values for the EnforcementMode const type. +func PossibleEnforcementModeValues() []EnforcementMode { + return []EnforcementMode{Audit, Enforce, None} +} + +// EnforcementSupport enumerates the values for enforcement support. +type EnforcementSupport string + +const ( + // EnforcementSupportNotSupported ... + EnforcementSupportNotSupported EnforcementSupport = "NotSupported" + // EnforcementSupportSupported ... + EnforcementSupportSupported EnforcementSupport = "Supported" + // EnforcementSupportUnknown ... + EnforcementSupportUnknown EnforcementSupport = "Unknown" +) + +// PossibleEnforcementSupportValues returns an array of possible values for the EnforcementSupport const type. +func PossibleEnforcementSupportValues() []EnforcementSupport { + return []EnforcementSupport{EnforcementSupportNotSupported, EnforcementSupportSupported, EnforcementSupportUnknown} +} + +// EventSource enumerates the values for event source. +type EventSource string + +const ( + // Alerts ... + Alerts EventSource = "Alerts" + // Assessments ... + Assessments EventSource = "Assessments" +) + +// PossibleEventSourceValues returns an array of possible values for the EventSource const type. +func PossibleEventSourceValues() []EventSource { + return []EventSource{Alerts, Assessments} +} + +// Exe enumerates the values for exe. +type Exe string + +const ( + // ExeAudit ... + ExeAudit Exe = "Audit" + // ExeEnforce ... + ExeEnforce Exe = "Enforce" + // ExeNone ... + ExeNone Exe = "None" +) + +// PossibleExeValues returns an array of possible values for the Exe const type. +func PossibleExeValues() []Exe { + return []Exe{ExeAudit, ExeEnforce, ExeNone} +} + +// Executable enumerates the values for executable. +type Executable string + +const ( + // ExecutableAudit ... + ExecutableAudit Executable = "Audit" + // ExecutableEnforce ... + ExecutableEnforce Executable = "Enforce" + // ExecutableNone ... + ExecutableNone Executable = "None" +) + +// PossibleExecutableValues returns an array of possible values for the Executable const type. +func PossibleExecutableValues() []Executable { + return []Executable{ExecutableAudit, ExecutableEnforce, ExecutableNone} +} + +// ExpandControlsEnum enumerates the values for expand controls enum. +type ExpandControlsEnum string + +const ( + // Definition Add definition object for each control + Definition ExpandControlsEnum = "definition" +) + +// PossibleExpandControlsEnumValues returns an array of possible values for the ExpandControlsEnum const type. +func PossibleExpandControlsEnumValues() []ExpandControlsEnum { + return []ExpandControlsEnum{Definition} +} + +// ExpandEnum enumerates the values for expand enum. +type ExpandEnum string + +const ( + // Links All links associated with an assessment + Links ExpandEnum = "links" + // Metadata Assessment metadata + Metadata ExpandEnum = "metadata" +) + +// PossibleExpandEnumValues returns an array of possible values for the ExpandEnum const type. +func PossibleExpandEnumValues() []ExpandEnum { + return []ExpandEnum{Links, Metadata} +} + +// ExportData enumerates the values for export data. +type ExportData string + +const ( + // RawEvents Agent raw events + RawEvents ExportData = "RawEvents" +) + +// PossibleExportDataValues returns an array of possible values for the ExportData const type. +func PossibleExportDataValues() []ExportData { + return []ExportData{RawEvents} +} + +// ExternalSecuritySolutionKind enumerates the values for external security solution kind. +type ExternalSecuritySolutionKind string + +const ( + // AAD ... + AAD ExternalSecuritySolutionKind = "AAD" + // ATA ... + ATA ExternalSecuritySolutionKind = "ATA" + // CEF ... + CEF ExternalSecuritySolutionKind = "CEF" +) + +// PossibleExternalSecuritySolutionKindValues returns an array of possible values for the ExternalSecuritySolutionKind const type. +func PossibleExternalSecuritySolutionKindValues() []ExternalSecuritySolutionKind { + return []ExternalSecuritySolutionKind{AAD, ATA, CEF} +} + +// Family enumerates the values for family. +type Family string + +const ( + // Ngfw ... + Ngfw Family = "Ngfw" + // SaasWaf ... + SaasWaf Family = "SaasWaf" + // Va ... + Va Family = "Va" + // Waf ... + Waf Family = "Waf" +) + +// PossibleFamilyValues returns an array of possible values for the Family const type. +func PossibleFamilyValues() []Family { + return []Family{Ngfw, SaasWaf, Va, Waf} +} + +// FileType enumerates the values for file type. +type FileType string + +const ( + // FileTypeDll ... + FileTypeDll FileType = "Dll" + // FileTypeExe ... + FileTypeExe FileType = "Exe" + // FileTypeExecutable ... + FileTypeExecutable FileType = "Executable" + // FileTypeMsi ... + FileTypeMsi FileType = "Msi" + // FileTypeScript ... + FileTypeScript FileType = "Script" + // FileTypeUnknown ... + FileTypeUnknown FileType = "Unknown" +) + +// PossibleFileTypeValues returns an array of possible values for the FileType const type. +func PossibleFileTypeValues() []FileType { + return []FileType{FileTypeDll, FileTypeExe, FileTypeExecutable, FileTypeMsi, FileTypeScript, FileTypeUnknown} +} + +// HybridComputeProvisioningState enumerates the values for hybrid compute provisioning state. +type HybridComputeProvisioningState string + +const ( + // HybridComputeProvisioningStateExpired the service principal details are expired + HybridComputeProvisioningStateExpired HybridComputeProvisioningState = "Expired" + // HybridComputeProvisioningStateInvalid Invalid service principal details. + HybridComputeProvisioningStateInvalid HybridComputeProvisioningState = "Invalid" + // HybridComputeProvisioningStateValid Valid service principal details. + HybridComputeProvisioningStateValid HybridComputeProvisioningState = "Valid" +) + +// PossibleHybridComputeProvisioningStateValues returns an array of possible values for the HybridComputeProvisioningState const type. +func PossibleHybridComputeProvisioningStateValues() []HybridComputeProvisioningState { + return []HybridComputeProvisioningState{HybridComputeProvisioningStateExpired, HybridComputeProvisioningStateInvalid, HybridComputeProvisioningStateValid} +} + +// ImplementationEffort enumerates the values for implementation effort. +type ImplementationEffort string + +const ( + // ImplementationEffortHigh ... + ImplementationEffortHigh ImplementationEffort = "High" + // ImplementationEffortLow ... + ImplementationEffortLow ImplementationEffort = "Low" + // ImplementationEffortModerate ... + ImplementationEffortModerate ImplementationEffort = "Moderate" +) + +// PossibleImplementationEffortValues returns an array of possible values for the ImplementationEffort const type. +func PossibleImplementationEffortValues() []ImplementationEffort { + return []ImplementationEffort{ImplementationEffortHigh, ImplementationEffortLow, ImplementationEffortModerate} +} + +// Issue enumerates the values for issue. +type Issue string + +const ( + // ExecutableViolationsAudited ... + ExecutableViolationsAudited Issue = "ExecutableViolationsAudited" + // MsiAndScriptViolationsAudited ... + MsiAndScriptViolationsAudited Issue = "MsiAndScriptViolationsAudited" + // MsiAndScriptViolationsBlocked ... + MsiAndScriptViolationsBlocked Issue = "MsiAndScriptViolationsBlocked" + // RulesViolatedManually ... + RulesViolatedManually Issue = "RulesViolatedManually" + // ViolationsAudited ... + ViolationsAudited Issue = "ViolationsAudited" + // ViolationsBlocked ... + ViolationsBlocked Issue = "ViolationsBlocked" +) + +// PossibleIssueValues returns an array of possible values for the Issue const type. +func PossibleIssueValues() []Issue { + return []Issue{ExecutableViolationsAudited, MsiAndScriptViolationsAudited, MsiAndScriptViolationsBlocked, RulesViolatedManually, ViolationsAudited, ViolationsBlocked} +} + +// KindEnum enumerates the values for kind enum. +type KindEnum string + +const ( + // KindDataExportSettings ... + KindDataExportSettings KindEnum = "DataExportSettings" + // KindSetting ... + KindSetting KindEnum = "Setting" + // KindSettingResource ... + KindSettingResource KindEnum = "SettingResource" +) + +// PossibleKindEnumValues returns an array of possible values for the KindEnum const type. +func PossibleKindEnumValues() []KindEnum { + return []KindEnum{KindDataExportSettings, KindSetting, KindSettingResource} +} + +// KindEnum1 enumerates the values for kind enum 1. +type KindEnum1 string + +const ( + // KindAAD ... + KindAAD KindEnum1 = "AAD" + // KindATA ... + KindATA KindEnum1 = "ATA" + // KindCEF ... + KindCEF KindEnum1 = "CEF" + // KindExternalSecuritySolution ... + KindExternalSecuritySolution KindEnum1 = "ExternalSecuritySolution" +) + +// PossibleKindEnum1Values returns an array of possible values for the KindEnum1 const type. +func PossibleKindEnum1Values() []KindEnum1 { + return []KindEnum1{KindAAD, KindATA, KindCEF, KindExternalSecuritySolution} +} + +// Msi enumerates the values for msi. +type Msi string + +const ( + // MsiAudit ... + MsiAudit Msi = "Audit" + // MsiEnforce ... + MsiEnforce Msi = "Enforce" + // MsiNone ... + MsiNone Msi = "None" +) + +// PossibleMsiValues returns an array of possible values for the Msi const type. +func PossibleMsiValues() []Msi { + return []Msi{MsiAudit, MsiEnforce, MsiNone} +} + +// Operator enumerates the values for operator. +type Operator string + +const ( + // Contains ... + Contains Operator = "Contains" + // EndsWith ... + EndsWith Operator = "EndsWith" + // Equals ... + Equals Operator = "Equals" + // GreaterThan ... + GreaterThan Operator = "GreaterThan" + // GreaterThanOrEqualTo ... + GreaterThanOrEqualTo Operator = "GreaterThanOrEqualTo" + // LesserThan ... + LesserThan Operator = "LesserThan" + // LesserThanOrEqualTo ... + LesserThanOrEqualTo Operator = "LesserThanOrEqualTo" + // NotEquals ... + NotEquals Operator = "NotEquals" + // StartsWith ... + StartsWith Operator = "StartsWith" +) + +// PossibleOperatorValues returns an array of possible values for the Operator const type. +func PossibleOperatorValues() []Operator { + return []Operator{Contains, EndsWith, Equals, GreaterThan, GreaterThanOrEqualTo, LesserThan, LesserThanOrEqualTo, NotEquals, StartsWith} +} + +// PermissionProperty enumerates the values for permission property. +type PermissionProperty string + +const ( + // AWSAmazonSSMAutomationRole The permission provides for EC2 Automation service to execute activities + // defined within Automation documents. + AWSAmazonSSMAutomationRole PermissionProperty = "AWS::AmazonSSMAutomationRole" + // AWSAWSSecurityHubReadOnlyAccess This permission provides read only access to AWS Security Hub resources. + AWSAWSSecurityHubReadOnlyAccess PermissionProperty = "AWS::AWSSecurityHubReadOnlyAccess" + // AWSSecurityAudit This permission grants access to read security configuration metadata. + AWSSecurityAudit PermissionProperty = "AWS::SecurityAudit" + // GCPSecurityCenterAdminViewer This permission provides read only access to GCP Security Command Center. + GCPSecurityCenterAdminViewer PermissionProperty = "GCP::Security Center Admin Viewer" +) + +// PossiblePermissionPropertyValues returns an array of possible values for the PermissionProperty const type. +func PossiblePermissionPropertyValues() []PermissionProperty { + return []PermissionProperty{AWSAmazonSSMAutomationRole, AWSAWSSecurityHubReadOnlyAccess, AWSSecurityAudit, GCPSecurityCenterAdminViewer} +} + +// PricingTier enumerates the values for pricing tier. +type PricingTier string + +const ( + // Free Get free Azure security center experience with basic security features + Free PricingTier = "Free" + // Standard Get the standard Azure security center experience with advanced security features + Standard PricingTier = "Standard" +) + +// PossiblePricingTierValues returns an array of possible values for the PricingTier const type. +func PossiblePricingTierValues() []PricingTier { + return []PricingTier{Free, Standard} +} + +// PropertyType enumerates the values for property type. +type PropertyType string + +const ( + // Boolean ... + Boolean PropertyType = "Boolean" + // Integer ... + Integer PropertyType = "Integer" + // Number ... + Number PropertyType = "Number" + // String ... + String PropertyType = "String" +) + +// PossiblePropertyTypeValues returns an array of possible values for the PropertyType const type. +func PossiblePropertyTypeValues() []PropertyType { + return []PropertyType{Boolean, Integer, Number, String} +} + +// Protocol enumerates the values for protocol. +type Protocol string + +const ( + // All ... + All Protocol = "*" + // TCP ... + TCP Protocol = "TCP" + // UDP ... + UDP Protocol = "UDP" +) + +// PossibleProtocolValues returns an array of possible values for the Protocol const type. +func PossibleProtocolValues() []Protocol { + return []Protocol{All, TCP, UDP} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating ... + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateFailed, ProvisioningStateSucceeded, ProvisioningStateUpdating} +} + +// ProvisioningState1 enumerates the values for provisioning state 1. +type ProvisioningState1 string + +const ( + // ProvisioningState1Canceled ... + ProvisioningState1Canceled ProvisioningState1 = "Canceled" + // ProvisioningState1Deprovisioning ... + ProvisioningState1Deprovisioning ProvisioningState1 = "Deprovisioning" + // ProvisioningState1Failed ... + ProvisioningState1Failed ProvisioningState1 = "Failed" + // ProvisioningState1Provisioning ... + ProvisioningState1Provisioning ProvisioningState1 = "Provisioning" + // ProvisioningState1Succeeded ... + ProvisioningState1Succeeded ProvisioningState1 = "Succeeded" +) + +// PossibleProvisioningState1Values returns an array of possible values for the ProvisioningState1 const type. +func PossibleProvisioningState1Values() []ProvisioningState1 { + return []ProvisioningState1{ProvisioningState1Canceled, ProvisioningState1Deprovisioning, ProvisioningState1Failed, ProvisioningState1Provisioning, ProvisioningState1Succeeded} +} + +// Rank enumerates the values for rank. +type Rank string + +const ( + // RankCritical ... + RankCritical Rank = "Critical" + // RankHigh ... + RankHigh Rank = "High" + // RankLow ... + RankLow Rank = "Low" + // RankMedium ... + RankMedium Rank = "Medium" + // RankNone ... + RankNone Rank = "None" +) + +// PossibleRankValues returns an array of possible values for the Rank const type. +func PossibleRankValues() []Rank { + return []Rank{RankCritical, RankHigh, RankLow, RankMedium, RankNone} +} + +// RecommendationAction enumerates the values for recommendation action. +type RecommendationAction string + +const ( + // RecommendationActionAdd ... + RecommendationActionAdd RecommendationAction = "Add" + // RecommendationActionRecommended ... + RecommendationActionRecommended RecommendationAction = "Recommended" + // RecommendationActionRemove ... + RecommendationActionRemove RecommendationAction = "Remove" +) + +// PossibleRecommendationActionValues returns an array of possible values for the RecommendationAction const type. +func PossibleRecommendationActionValues() []RecommendationAction { + return []RecommendationAction{RecommendationActionAdd, RecommendationActionRecommended, RecommendationActionRemove} +} + +// RecommendationAction1 enumerates the values for recommendation action 1. +type RecommendationAction1 string + +const ( + // RecommendationAction1Add ... + RecommendationAction1Add RecommendationAction1 = "Add" + // RecommendationAction1Recommended ... + RecommendationAction1Recommended RecommendationAction1 = "Recommended" + // RecommendationAction1Remove ... + RecommendationAction1Remove RecommendationAction1 = "Remove" +) + +// PossibleRecommendationAction1Values returns an array of possible values for the RecommendationAction1 const type. +func PossibleRecommendationAction1Values() []RecommendationAction1 { + return []RecommendationAction1{RecommendationAction1Add, RecommendationAction1Recommended, RecommendationAction1Remove} +} + +// RecommendationConfigStatus enumerates the values for recommendation config status. +type RecommendationConfigStatus string + +const ( + // Disabled ... + Disabled RecommendationConfigStatus = "Disabled" + // Enabled ... + Enabled RecommendationConfigStatus = "Enabled" +) + +// PossibleRecommendationConfigStatusValues returns an array of possible values for the RecommendationConfigStatus const type. +func PossibleRecommendationConfigStatusValues() []RecommendationConfigStatus { + return []RecommendationConfigStatus{Disabled, Enabled} +} + +// RecommendationSeverity enumerates the values for recommendation severity. +type RecommendationSeverity string + +const ( + // RecommendationSeverityHealthy ... + RecommendationSeverityHealthy RecommendationSeverity = "Healthy" + // RecommendationSeverityHigh ... + RecommendationSeverityHigh RecommendationSeverity = "High" + // RecommendationSeverityLow ... + RecommendationSeverityLow RecommendationSeverity = "Low" + // RecommendationSeverityMedium ... + RecommendationSeverityMedium RecommendationSeverity = "Medium" + // RecommendationSeverityNotApplicable ... + RecommendationSeverityNotApplicable RecommendationSeverity = "NotApplicable" + // RecommendationSeverityOffByPolicy ... + RecommendationSeverityOffByPolicy RecommendationSeverity = "OffByPolicy" + // RecommendationSeverityUnknown ... + RecommendationSeverityUnknown RecommendationSeverity = "Unknown" +) + +// PossibleRecommendationSeverityValues returns an array of possible values for the RecommendationSeverity const type. +func PossibleRecommendationSeverityValues() []RecommendationSeverity { + return []RecommendationSeverity{RecommendationSeverityHealthy, RecommendationSeverityHigh, RecommendationSeverityLow, RecommendationSeverityMedium, RecommendationSeverityNotApplicable, RecommendationSeverityOffByPolicy, RecommendationSeverityUnknown} +} + +// RecommendationStatus enumerates the values for recommendation status. +type RecommendationStatus string + +const ( + // RecommendationStatusNoStatus ... + RecommendationStatusNoStatus RecommendationStatus = "NoStatus" + // RecommendationStatusNotAvailable ... + RecommendationStatusNotAvailable RecommendationStatus = "NotAvailable" + // RecommendationStatusNotRecommended ... + RecommendationStatusNotRecommended RecommendationStatus = "NotRecommended" + // RecommendationStatusRecommended ... + RecommendationStatusRecommended RecommendationStatus = "Recommended" +) + +// PossibleRecommendationStatusValues returns an array of possible values for the RecommendationStatus const type. +func PossibleRecommendationStatusValues() []RecommendationStatus { + return []RecommendationStatus{RecommendationStatusNoStatus, RecommendationStatusNotAvailable, RecommendationStatusNotRecommended, RecommendationStatusRecommended} +} + +// RecommendationType enumerates the values for recommendation type. +type RecommendationType string + +const ( + // IoTACRAuthentication Authentication schema used for pull an edge module from an ACR repository does not + // use Service Principal Authentication. + IoTACRAuthentication RecommendationType = "IoT_ACRAuthentication" + // IoTAgentSendsUnutilizedMessages IoT agent message size capacity is currently underutilized, causing an + // increase in the number of sent messages. Adjust message intervals for better utilization. + IoTAgentSendsUnutilizedMessages RecommendationType = "IoT_AgentSendsUnutilizedMessages" + // IoTBaseline Identified security related system configuration issues. + IoTBaseline RecommendationType = "IoT_Baseline" + // IoTEdgeHubMemOptimize You can optimize Edge Hub memory usage by turning off protocol heads for any + // protocols not used by Edge modules in your solution. + IoTEdgeHubMemOptimize RecommendationType = "IoT_EdgeHubMemOptimize" + // IoTEdgeLoggingOptions Logging is disabled for this edge module. + IoTEdgeLoggingOptions RecommendationType = "IoT_EdgeLoggingOptions" + // IoTInconsistentModuleSettings A minority within a device security group has inconsistent Edge Module + // settings with the rest of their group. + IoTInconsistentModuleSettings RecommendationType = "IoT_InconsistentModuleSettings" + // IoTInstallAgent Install the Azure Security of Things Agent. + IoTInstallAgent RecommendationType = "IoT_InstallAgent" + // IoTIPFilterDenyAll IP Filter Configuration should have rules defined for allowed traffic and should deny + // all other traffic by default. + IoTIPFilterDenyAll RecommendationType = "IoT_IPFilter_DenyAll" + // IoTIPFilterPermissiveRule An Allow IP Filter rules source IP range is too large. Overly permissive rules + // might expose your IoT hub to malicious intenders. + IoTIPFilterPermissiveRule RecommendationType = "IoT_IPFilter_PermissiveRule" + // IoTOpenPorts A listening endpoint was found on the device. + IoTOpenPorts RecommendationType = "IoT_OpenPorts" + // IoTPermissiveFirewallPolicy An Allowed firewall policy was found (INPUT/OUTPUT). The policy should Deny + // all traffic by default and define rules to allow necessary communication to/from the device. + IoTPermissiveFirewallPolicy RecommendationType = "IoT_PermissiveFirewallPolicy" + // IoTPermissiveInputFirewallRules A rule in the firewall has been found that contains a permissive pattern + // for a wide range of IP addresses or Ports. + IoTPermissiveInputFirewallRules RecommendationType = "IoT_PermissiveInputFirewallRules" + // IoTPermissiveOutputFirewallRules A rule in the firewall has been found that contains a permissive + // pattern for a wide range of IP addresses or Ports. + IoTPermissiveOutputFirewallRules RecommendationType = "IoT_PermissiveOutputFirewallRules" + // IoTPrivilegedDockerOptions Edge module is configured to run in privileged mode, with extensive Linux + // capabilities or with host-level network access (send/receive data to host machine). + IoTPrivilegedDockerOptions RecommendationType = "IoT_PrivilegedDockerOptions" + // IoTSharedCredentials Same authentication credentials to the IoT Hub used by multiple devices. This could + // indicate an illegitimate device impersonating a legitimate device. It also exposes the risk of device + // impersonation by an attacker. + IoTSharedCredentials RecommendationType = "IoT_SharedCredentials" + // IoTVulnerableTLSCipherSuite Insecure TLS configurations detected. Immediate upgrade recommended. + IoTVulnerableTLSCipherSuite RecommendationType = "IoT_VulnerableTLSCipherSuite" +) + +// PossibleRecommendationTypeValues returns an array of possible values for the RecommendationType const type. +func PossibleRecommendationTypeValues() []RecommendationType { + return []RecommendationType{IoTACRAuthentication, IoTAgentSendsUnutilizedMessages, IoTBaseline, IoTEdgeHubMemOptimize, IoTEdgeLoggingOptions, IoTInconsistentModuleSettings, IoTInstallAgent, IoTIPFilterDenyAll, IoTIPFilterPermissiveRule, IoTOpenPorts, IoTPermissiveFirewallPolicy, IoTPermissiveInputFirewallRules, IoTPermissiveOutputFirewallRules, IoTPrivilegedDockerOptions, IoTSharedCredentials, IoTVulnerableTLSCipherSuite} +} + +// ReportedSeverity enumerates the values for reported severity. +type ReportedSeverity string + +const ( + // ReportedSeverityHigh ... + ReportedSeverityHigh ReportedSeverity = "High" + // ReportedSeverityInformational ... + ReportedSeverityInformational ReportedSeverity = "Informational" + // ReportedSeverityLow ... + ReportedSeverityLow ReportedSeverity = "Low" + // ReportedSeverityMedium ... + ReportedSeverityMedium ReportedSeverity = "Medium" +) + +// PossibleReportedSeverityValues returns an array of possible values for the ReportedSeverity const type. +func PossibleReportedSeverityValues() []ReportedSeverity { + return []ReportedSeverity{ReportedSeverityHigh, ReportedSeverityInformational, ReportedSeverityLow, ReportedSeverityMedium} +} + +// ResourceStatus enumerates the values for resource status. +type ResourceStatus string + +const ( + // ResourceStatusHealthy This assessment on the resource is healthy + ResourceStatusHealthy ResourceStatus = "Healthy" + // ResourceStatusNotApplicable This assessment is not applicable to this resource + ResourceStatusNotApplicable ResourceStatus = "NotApplicable" + // ResourceStatusNotHealthy This assessment on the resource is not healthy + ResourceStatusNotHealthy ResourceStatus = "NotHealthy" + // ResourceStatusOffByPolicy This assessment is turned off by policy on this subscription + ResourceStatusOffByPolicy ResourceStatus = "OffByPolicy" +) + +// PossibleResourceStatusValues returns an array of possible values for the ResourceStatus const type. +func PossibleResourceStatusValues() []ResourceStatus { + return []ResourceStatus{ResourceStatusHealthy, ResourceStatusNotApplicable, ResourceStatusNotHealthy, ResourceStatusOffByPolicy} +} + +// RuleState enumerates the values for rule state. +type RuleState string + +const ( + // RuleStateDisabled ... + RuleStateDisabled RuleState = "Disabled" + // RuleStateEnabled ... + RuleStateEnabled RuleState = "Enabled" + // RuleStateExpired ... + RuleStateExpired RuleState = "Expired" +) + +// PossibleRuleStateValues returns an array of possible values for the RuleState const type. +func PossibleRuleStateValues() []RuleState { + return []RuleState{RuleStateDisabled, RuleStateEnabled, RuleStateExpired} +} + +// RuleType enumerates the values for rule type. +type RuleType string + +const ( + // RuleTypeActiveConnectionsNotInAllowedRange ... + RuleTypeActiveConnectionsNotInAllowedRange RuleType = "ActiveConnectionsNotInAllowedRange" + // RuleTypeAllowlistCustomAlertRule ... + RuleTypeAllowlistCustomAlertRule RuleType = "AllowlistCustomAlertRule" + // RuleTypeAmqpC2DMessagesNotInAllowedRange ... + RuleTypeAmqpC2DMessagesNotInAllowedRange RuleType = "AmqpC2DMessagesNotInAllowedRange" + // RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange ... + RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange RuleType = "AmqpC2DRejectedMessagesNotInAllowedRange" + // RuleTypeAmqpD2CMessagesNotInAllowedRange ... + RuleTypeAmqpD2CMessagesNotInAllowedRange RuleType = "AmqpD2CMessagesNotInAllowedRange" + // RuleTypeConnectionToIPNotAllowed ... + RuleTypeConnectionToIPNotAllowed RuleType = "ConnectionToIpNotAllowed" + // RuleTypeCustomAlertRule ... + RuleTypeCustomAlertRule RuleType = "CustomAlertRule" + // RuleTypeDenylistCustomAlertRule ... + RuleTypeDenylistCustomAlertRule RuleType = "DenylistCustomAlertRule" + // RuleTypeDirectMethodInvokesNotInAllowedRange ... + RuleTypeDirectMethodInvokesNotInAllowedRange RuleType = "DirectMethodInvokesNotInAllowedRange" + // RuleTypeFailedLocalLoginsNotInAllowedRange ... + RuleTypeFailedLocalLoginsNotInAllowedRange RuleType = "FailedLocalLoginsNotInAllowedRange" + // RuleTypeFileUploadsNotInAllowedRange ... + RuleTypeFileUploadsNotInAllowedRange RuleType = "FileUploadsNotInAllowedRange" + // RuleTypeHTTPC2DMessagesNotInAllowedRange ... + RuleTypeHTTPC2DMessagesNotInAllowedRange RuleType = "HttpC2DMessagesNotInAllowedRange" + // RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange ... + RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange RuleType = "HttpC2DRejectedMessagesNotInAllowedRange" + // RuleTypeHTTPD2CMessagesNotInAllowedRange ... + RuleTypeHTTPD2CMessagesNotInAllowedRange RuleType = "HttpD2CMessagesNotInAllowedRange" + // RuleTypeListCustomAlertRule ... + RuleTypeListCustomAlertRule RuleType = "ListCustomAlertRule" + // RuleTypeLocalUserNotAllowed ... + RuleTypeLocalUserNotAllowed RuleType = "LocalUserNotAllowed" + // RuleTypeMqttC2DMessagesNotInAllowedRange ... + RuleTypeMqttC2DMessagesNotInAllowedRange RuleType = "MqttC2DMessagesNotInAllowedRange" + // RuleTypeMqttC2DRejectedMessagesNotInAllowedRange ... + RuleTypeMqttC2DRejectedMessagesNotInAllowedRange RuleType = "MqttC2DRejectedMessagesNotInAllowedRange" + // RuleTypeMqttD2CMessagesNotInAllowedRange ... + RuleTypeMqttD2CMessagesNotInAllowedRange RuleType = "MqttD2CMessagesNotInAllowedRange" + // RuleTypeProcessNotAllowed ... + RuleTypeProcessNotAllowed RuleType = "ProcessNotAllowed" + // RuleTypeQueuePurgesNotInAllowedRange ... + RuleTypeQueuePurgesNotInAllowedRange RuleType = "QueuePurgesNotInAllowedRange" + // RuleTypeThresholdCustomAlertRule ... + RuleTypeThresholdCustomAlertRule RuleType = "ThresholdCustomAlertRule" + // RuleTypeTimeWindowCustomAlertRule ... + RuleTypeTimeWindowCustomAlertRule RuleType = "TimeWindowCustomAlertRule" + // RuleTypeTwinUpdatesNotInAllowedRange ... + RuleTypeTwinUpdatesNotInAllowedRange RuleType = "TwinUpdatesNotInAllowedRange" + // RuleTypeUnauthorizedOperationsNotInAllowedRange ... + RuleTypeUnauthorizedOperationsNotInAllowedRange RuleType = "UnauthorizedOperationsNotInAllowedRange" +) + +// PossibleRuleTypeValues returns an array of possible values for the RuleType const type. +func PossibleRuleTypeValues() []RuleType { + return []RuleType{RuleTypeActiveConnectionsNotInAllowedRange, RuleTypeAllowlistCustomAlertRule, RuleTypeAmqpC2DMessagesNotInAllowedRange, RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange, RuleTypeAmqpD2CMessagesNotInAllowedRange, RuleTypeConnectionToIPNotAllowed, RuleTypeCustomAlertRule, RuleTypeDenylistCustomAlertRule, RuleTypeDirectMethodInvokesNotInAllowedRange, RuleTypeFailedLocalLoginsNotInAllowedRange, RuleTypeFileUploadsNotInAllowedRange, RuleTypeHTTPC2DMessagesNotInAllowedRange, RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange, RuleTypeHTTPD2CMessagesNotInAllowedRange, RuleTypeListCustomAlertRule, RuleTypeLocalUserNotAllowed, RuleTypeMqttC2DMessagesNotInAllowedRange, RuleTypeMqttC2DRejectedMessagesNotInAllowedRange, RuleTypeMqttD2CMessagesNotInAllowedRange, RuleTypeProcessNotAllowed, RuleTypeQueuePurgesNotInAllowedRange, RuleTypeThresholdCustomAlertRule, RuleTypeTimeWindowCustomAlertRule, RuleTypeTwinUpdatesNotInAllowedRange, RuleTypeUnauthorizedOperationsNotInAllowedRange} +} + +// Script enumerates the values for script. +type Script string + +const ( + // ScriptAudit ... + ScriptAudit Script = "Audit" + // ScriptEnforce ... + ScriptEnforce Script = "Enforce" + // ScriptNone ... + ScriptNone Script = "None" +) + +// PossibleScriptValues returns an array of possible values for the Script const type. +func PossibleScriptValues() []Script { + return []Script{ScriptAudit, ScriptEnforce, ScriptNone} +} + +// Severity enumerates the values for severity. +type Severity string + +const ( + // SeverityHigh ... + SeverityHigh Severity = "High" + // SeverityLow ... + SeverityLow Severity = "Low" + // SeverityMedium ... + SeverityMedium Severity = "Medium" +) + +// PossibleSeverityValues returns an array of possible values for the Severity const type. +func PossibleSeverityValues() []Severity { + return []Severity{SeverityHigh, SeverityLow, SeverityMedium} +} + +// SolutionStatus enumerates the values for solution status. +type SolutionStatus string + +const ( + // SolutionStatusDisabled ... + SolutionStatusDisabled SolutionStatus = "Disabled" + // SolutionStatusEnabled ... + SolutionStatusEnabled SolutionStatus = "Enabled" +) + +// PossibleSolutionStatusValues returns an array of possible values for the SolutionStatus const type. +func PossibleSolutionStatusValues() []SolutionStatus { + return []SolutionStatus{SolutionStatusDisabled, SolutionStatusEnabled} +} + +// Source enumerates the values for source. +type Source string + +const ( + // SourceAzure ... + SourceAzure Source = "Azure" + // SourceOnPremise ... + SourceOnPremise Source = "OnPremise" + // SourceOnPremiseSQL ... + SourceOnPremiseSQL Source = "OnPremiseSql" + // SourceResourceDetails ... + SourceResourceDetails Source = "ResourceDetails" +) + +// PossibleSourceValues returns an array of possible values for the Source const type. +func PossibleSourceValues() []Source { + return []Source{SourceAzure, SourceOnPremise, SourceOnPremiseSQL, SourceResourceDetails} +} + +// SourceSystem enumerates the values for source system. +type SourceSystem string + +const ( + // SourceSystemAzureAppLocker ... + SourceSystemAzureAppLocker SourceSystem = "Azure_AppLocker" + // SourceSystemAzureAuditD ... + SourceSystemAzureAuditD SourceSystem = "Azure_AuditD" + // SourceSystemNonAzureAppLocker ... + SourceSystemNonAzureAppLocker SourceSystem = "NonAzure_AppLocker" + // SourceSystemNonAzureAuditD ... + SourceSystemNonAzureAuditD SourceSystem = "NonAzure_AuditD" + // SourceSystemNone ... + SourceSystemNone SourceSystem = "None" +) + +// PossibleSourceSystemValues returns an array of possible values for the SourceSystem const type. +func PossibleSourceSystemValues() []SourceSystem { + return []SourceSystem{SourceSystemAzureAppLocker, SourceSystemAzureAuditD, SourceSystemNonAzureAppLocker, SourceSystemNonAzureAuditD, SourceSystemNone} +} + +// State enumerates the values for state. +type State string + +const ( + // StateFailed At least one supported regulatory compliance control in the given standard has a state of + // failed + StateFailed State = "Failed" + // StatePassed All supported regulatory compliance controls in the given standard have a passed state + StatePassed State = "Passed" + // StateSkipped All supported regulatory compliance controls in the given standard have a state of skipped + StateSkipped State = "Skipped" + // StateUnsupported No supported regulatory compliance data for the given standard + StateUnsupported State = "Unsupported" +) + +// PossibleStateValues returns an array of possible values for the State const type. +func PossibleStateValues() []State { + return []State{StateFailed, StatePassed, StateSkipped, StateUnsupported} +} + +// Status enumerates the values for status. +type Status string + +const ( + // Initiated ... + Initiated Status = "Initiated" + // Revoked ... + Revoked Status = "Revoked" +) + +// PossibleStatusValues returns an array of possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{Initiated, Revoked} +} + +// StatusReason enumerates the values for status reason. +type StatusReason string + +const ( + // StatusReasonExpired ... + StatusReasonExpired StatusReason = "Expired" + // StatusReasonNewerRequestInitiated ... + StatusReasonNewerRequestInitiated StatusReason = "NewerRequestInitiated" + // StatusReasonUserRequested ... + StatusReasonUserRequested StatusReason = "UserRequested" +) + +// PossibleStatusReasonValues returns an array of possible values for the StatusReason const type. +func PossibleStatusReasonValues() []StatusReason { + return []StatusReason{StatusReasonExpired, StatusReasonNewerRequestInitiated, StatusReasonUserRequested} +} + +// SubAssessmentStatusCode enumerates the values for sub assessment status code. +type SubAssessmentStatusCode string + +const ( + // SubAssessmentStatusCodeHealthy The resource is healthy + SubAssessmentStatusCodeHealthy SubAssessmentStatusCode = "Healthy" + // SubAssessmentStatusCodeNotApplicable Assessment for this resource did not happen + SubAssessmentStatusCodeNotApplicable SubAssessmentStatusCode = "NotApplicable" + // SubAssessmentStatusCodeUnhealthy The resource has a security issue that needs to be addressed + SubAssessmentStatusCodeUnhealthy SubAssessmentStatusCode = "Unhealthy" +) + +// PossibleSubAssessmentStatusCodeValues returns an array of possible values for the SubAssessmentStatusCode const type. +func PossibleSubAssessmentStatusCodeValues() []SubAssessmentStatusCode { + return []SubAssessmentStatusCode{SubAssessmentStatusCodeHealthy, SubAssessmentStatusCodeNotApplicable, SubAssessmentStatusCodeUnhealthy} +} + +// Threats enumerates the values for threats. +type Threats string + +const ( + // AccountBreach ... + AccountBreach Threats = "accountBreach" + // DataExfiltration ... + DataExfiltration Threats = "dataExfiltration" + // DataSpillage ... + DataSpillage Threats = "dataSpillage" + // DenialOfService ... + DenialOfService Threats = "denialOfService" + // ElevationOfPrivilege ... + ElevationOfPrivilege Threats = "elevationOfPrivilege" + // MaliciousInsider ... + MaliciousInsider Threats = "maliciousInsider" + // MissingCoverage ... + MissingCoverage Threats = "missingCoverage" + // ThreatResistance ... + ThreatResistance Threats = "threatResistance" +) + +// PossibleThreatsValues returns an array of possible values for the Threats const type. +func PossibleThreatsValues() []Threats { + return []Threats{AccountBreach, DataExfiltration, DataSpillage, DenialOfService, ElevationOfPrivilege, MaliciousInsider, MissingCoverage, ThreatResistance} +} + +// TransportProtocol enumerates the values for transport protocol. +type TransportProtocol string + +const ( + // TransportProtocolTCP ... + TransportProtocolTCP TransportProtocol = "TCP" + // TransportProtocolUDP ... + TransportProtocolUDP TransportProtocol = "UDP" +) + +// PossibleTransportProtocolValues returns an array of possible values for the TransportProtocol const type. +func PossibleTransportProtocolValues() []TransportProtocol { + return []TransportProtocol{TransportProtocolTCP, TransportProtocolUDP} +} + +// Type enumerates the values for type. +type Type string + +const ( + // BinarySignature ... + BinarySignature Type = "BinarySignature" + // File ... + File Type = "File" + // FileHash ... + FileHash Type = "FileHash" + // ProductSignature ... + ProductSignature Type = "ProductSignature" + // PublisherSignature ... + PublisherSignature Type = "PublisherSignature" + // VersionAndAboveSignature ... + VersionAndAboveSignature Type = "VersionAndAboveSignature" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{BinarySignature, File, FileHash, ProductSignature, PublisherSignature, VersionAndAboveSignature} +} + +// UnmaskedIPLoggingStatus enumerates the values for unmasked ip logging status. +type UnmaskedIPLoggingStatus string + +const ( + // UnmaskedIPLoggingStatusDisabled Unmasked IP logging is disabled + UnmaskedIPLoggingStatusDisabled UnmaskedIPLoggingStatus = "Disabled" + // UnmaskedIPLoggingStatusEnabled Unmasked IP logging is enabled + UnmaskedIPLoggingStatusEnabled UnmaskedIPLoggingStatus = "Enabled" +) + +// PossibleUnmaskedIPLoggingStatusValues returns an array of possible values for the UnmaskedIPLoggingStatus const type. +func PossibleUnmaskedIPLoggingStatusValues() []UnmaskedIPLoggingStatus { + return []UnmaskedIPLoggingStatus{UnmaskedIPLoggingStatusDisabled, UnmaskedIPLoggingStatusEnabled} +} + +// UserImpact enumerates the values for user impact. +type UserImpact string + +const ( + // UserImpactHigh ... + UserImpactHigh UserImpact = "High" + // UserImpactLow ... + UserImpactLow UserImpact = "Low" + // UserImpactModerate ... + UserImpactModerate UserImpact = "Moderate" +) + +// PossibleUserImpactValues returns an array of possible values for the UserImpact const type. +func PossibleUserImpactValues() []UserImpact { + return []UserImpact{UserImpactHigh, UserImpactLow, UserImpactModerate} +} + +// ValueType enumerates the values for value type. +type ValueType string + +const ( + // ValueTypeIPCidr An IP range in CIDR format (e.g. '192.168.0.1/8'). + ValueTypeIPCidr ValueType = "IpCidr" + // ValueTypeString Any string value. + ValueTypeString ValueType = "String" +) + +// PossibleValueTypeValues returns an array of possible values for the ValueType const type. +func PossibleValueTypeValues() []ValueType { + return []ValueType{ValueTypeIPCidr, ValueTypeString} +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/externalsecuritysolutions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/externalsecuritysolutions.go new file mode 100644 index 0000000000000..1ab1c466384ff --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/externalsecuritysolutions.go @@ -0,0 +1,366 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ExternalSecuritySolutionsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type ExternalSecuritySolutionsClient struct { + BaseClient +} + +// NewExternalSecuritySolutionsClient creates an instance of the ExternalSecuritySolutionsClient client. +func NewExternalSecuritySolutionsClient(subscriptionID string, ascLocation string) ExternalSecuritySolutionsClient { + return NewExternalSecuritySolutionsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewExternalSecuritySolutionsClientWithBaseURI creates an instance of the ExternalSecuritySolutionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewExternalSecuritySolutionsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) ExternalSecuritySolutionsClient { + return ExternalSecuritySolutionsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get gets a specific external Security Solution. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// externalSecuritySolutionsName - name of an external security solution. +func (client ExternalSecuritySolutionsClient) Get(ctx context.Context, resourceGroupName string, externalSecuritySolutionsName string) (result ExternalSecuritySolutionModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExternalSecuritySolutionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ExternalSecuritySolutionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, externalSecuritySolutionsName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ExternalSecuritySolutionsClient) GetPreparer(ctx context.Context, resourceGroupName string, externalSecuritySolutionsName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "externalSecuritySolutionsName": autorest.Encode("path", externalSecuritySolutionsName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions/{externalSecuritySolutionsName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ExternalSecuritySolutionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ExternalSecuritySolutionsClient) GetResponder(resp *http.Response) (result ExternalSecuritySolutionModel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of external security solutions for the subscription. +func (client ExternalSecuritySolutionsClient) List(ctx context.Context) (result ExternalSecuritySolutionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExternalSecuritySolutionsClient.List") + defer func() { + sc := -1 + if result.essl.Response.Response != nil { + sc = result.essl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ExternalSecuritySolutionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.essl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "List", resp, "Failure sending request") + return + } + + result.essl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "List", resp, "Failure responding to request") + } + if result.essl.hasNextLink() && result.essl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client ExternalSecuritySolutionsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/externalSecuritySolutions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ExternalSecuritySolutionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ExternalSecuritySolutionsClient) ListResponder(resp *http.Response) (result ExternalSecuritySolutionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ExternalSecuritySolutionsClient) listNextResults(ctx context.Context, lastResults ExternalSecuritySolutionList) (result ExternalSecuritySolutionList, err error) { + req, err := lastResults.externalSecuritySolutionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ExternalSecuritySolutionsClient) ListComplete(ctx context.Context) (result ExternalSecuritySolutionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExternalSecuritySolutionsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByHomeRegion gets a list of external Security Solutions for the subscription and location. +func (client ExternalSecuritySolutionsClient) ListByHomeRegion(ctx context.Context) (result ExternalSecuritySolutionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExternalSecuritySolutionsClient.ListByHomeRegion") + defer func() { + sc := -1 + if result.essl.Response.Response != nil { + sc = result.essl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ExternalSecuritySolutionsClient", "ListByHomeRegion", err.Error()) + } + + result.fn = client.listByHomeRegionNextResults + req, err := client.ListByHomeRegionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "ListByHomeRegion", nil, "Failure preparing request") + return + } + + resp, err := client.ListByHomeRegionSender(req) + if err != nil { + result.essl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "ListByHomeRegion", resp, "Failure sending request") + return + } + + result.essl, err = client.ListByHomeRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "ListByHomeRegion", resp, "Failure responding to request") + } + if result.essl.hasNextLink() && result.essl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByHomeRegionPreparer prepares the ListByHomeRegion request. +func (client ExternalSecuritySolutionsClient) ListByHomeRegionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByHomeRegionSender sends the ListByHomeRegion request. The method will close the +// http.Response Body if it receives an error. +func (client ExternalSecuritySolutionsClient) ListByHomeRegionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByHomeRegionResponder handles the response to the ListByHomeRegion request. The method always +// closes the http.Response Body. +func (client ExternalSecuritySolutionsClient) ListByHomeRegionResponder(resp *http.Response) (result ExternalSecuritySolutionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByHomeRegionNextResults retrieves the next set of results, if any. +func (client ExternalSecuritySolutionsClient) listByHomeRegionNextResults(ctx context.Context, lastResults ExternalSecuritySolutionList) (result ExternalSecuritySolutionList, err error) { + req, err := lastResults.externalSecuritySolutionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "listByHomeRegionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByHomeRegionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "listByHomeRegionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByHomeRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ExternalSecuritySolutionsClient", "listByHomeRegionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByHomeRegionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ExternalSecuritySolutionsClient) ListByHomeRegionComplete(ctx context.Context) (result ExternalSecuritySolutionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExternalSecuritySolutionsClient.ListByHomeRegion") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByHomeRegion(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/informationprotectionpolicies.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/informationprotectionpolicies.go new file mode 100644 index 0000000000000..22f070a193528 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/informationprotectionpolicies.go @@ -0,0 +1,310 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InformationProtectionPoliciesClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type InformationProtectionPoliciesClient struct { + BaseClient +} + +// NewInformationProtectionPoliciesClient creates an instance of the InformationProtectionPoliciesClient client. +func NewInformationProtectionPoliciesClient(subscriptionID string, ascLocation string) InformationProtectionPoliciesClient { + return NewInformationProtectionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewInformationProtectionPoliciesClientWithBaseURI creates an instance of the InformationProtectionPoliciesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewInformationProtectionPoliciesClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) InformationProtectionPoliciesClient { + return InformationProtectionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// CreateOrUpdate details of the information protection policy. +// Parameters: +// scope - scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or +// management group (/providers/Microsoft.Management/managementGroups/mgName). +// informationProtectionPolicyName - name of the information protection policy. +// informationProtectionPolicy - information protection policy. +func (client InformationProtectionPoliciesClient) CreateOrUpdate(ctx context.Context, scope string, informationProtectionPolicyName string, informationProtectionPolicy InformationProtectionPolicy) (result InformationProtectionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InformationProtectionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, scope, informationProtectionPolicyName, informationProtectionPolicy) + if err != nil { + err = autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client InformationProtectionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, scope string, informationProtectionPolicyName string, informationProtectionPolicy InformationProtectionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "informationProtectionPolicyName": autorest.Encode("path", informationProtectionPolicyName), + "scope": scope, + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}", pathParameters), + autorest.WithJSON(informationProtectionPolicy), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client InformationProtectionPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client InformationProtectionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result InformationProtectionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get details of the information protection policy. +// Parameters: +// scope - scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or +// management group (/providers/Microsoft.Management/managementGroups/mgName). +// informationProtectionPolicyName - name of the information protection policy. +func (client InformationProtectionPoliciesClient) Get(ctx context.Context, scope string, informationProtectionPolicyName string) (result InformationProtectionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InformationProtectionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, scope, informationProtectionPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client InformationProtectionPoliciesClient) GetPreparer(ctx context.Context, scope string, informationProtectionPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "informationProtectionPolicyName": autorest.Encode("path", informationProtectionPolicyName), + "scope": scope, + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client InformationProtectionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InformationProtectionPoliciesClient) GetResponder(resp *http.Response) (result InformationProtectionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List information protection policies of a specific management group. +// Parameters: +// scope - scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or +// management group (/providers/Microsoft.Management/managementGroups/mgName). +func (client InformationProtectionPoliciesClient) List(ctx context.Context, scope string) (result InformationProtectionPolicyListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InformationProtectionPoliciesClient.List") + defer func() { + sc := -1 + if result.ippl.Response.Response != nil { + sc = result.ippl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ippl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "List", resp, "Failure sending request") + return + } + + result.ippl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "List", resp, "Failure responding to request") + } + if result.ippl.hasNextLink() && result.ippl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client InformationProtectionPoliciesClient) ListPreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Security/informationProtectionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client InformationProtectionPoliciesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client InformationProtectionPoliciesClient) ListResponder(resp *http.Response) (result InformationProtectionPolicyList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client InformationProtectionPoliciesClient) listNextResults(ctx context.Context, lastResults InformationProtectionPolicyList) (result InformationProtectionPolicyList, err error) { + req, err := lastResults.informationProtectionPolicyListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.InformationProtectionPoliciesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client InformationProtectionPoliciesClient) ListComplete(ctx context.Context, scope string) (result InformationProtectionPolicyListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InformationProtectionPoliciesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, scope) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotalerts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotalerts.go new file mode 100644 index 0000000000000..9058b8a9d07a3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotalerts.go @@ -0,0 +1,278 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotAlertsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type IotAlertsClient struct { + BaseClient +} + +// NewIotAlertsClient creates an instance of the IotAlertsClient client. +func NewIotAlertsClient(subscriptionID string, ascLocation string) IotAlertsClient { + return NewIotAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIotAlertsClientWithBaseURI creates an instance of the IotAlertsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewIotAlertsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IotAlertsClient { + return IotAlertsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get IoT alert +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// iotAlertID - id of the alert +func (client IotAlertsClient) Get(ctx context.Context, resourceGroupName string, solutionName string, iotAlertID string) (result IotAlert, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotAlertsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotAlertsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, solutionName, iotAlertID) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotAlertsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotAlertsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotAlertsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotAlertsClient) GetPreparer(ctx context.Context, resourceGroupName string, solutionName string, iotAlertID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotAlertId": autorest.Encode("path", iotAlertID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotAlerts/{iotAlertId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotAlertsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotAlertsClient) GetResponder(resp *http.Response) (result IotAlert, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list IoT alerts +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// minStartTimeUtc - filter by minimum startTimeUtc (ISO 8601 format) +// maxStartTimeUtc - filter by maximum startTimeUtc (ISO 8601 format) +// alertType - filter by alert type +// limit - limit the number of items returned in a single page +// skipToken - skip token used for pagination +func (client IotAlertsClient) List(ctx context.Context, resourceGroupName string, solutionName string, minStartTimeUtc string, maxStartTimeUtc string, alertType string, limit *int32, skipToken string) (result IotAlertListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotAlertsClient.List") + defer func() { + sc := -1 + if result.ial.Response.Response != nil { + sc = result.ial.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotAlertsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, solutionName, minStartTimeUtc, maxStartTimeUtc, alertType, limit, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotAlertsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ial.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotAlertsClient", "List", resp, "Failure sending request") + return + } + + result.ial, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotAlertsClient", "List", resp, "Failure responding to request") + } + if result.ial.hasNextLink() && result.ial.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client IotAlertsClient) ListPreparer(ctx context.Context, resourceGroupName string, solutionName string, minStartTimeUtc string, maxStartTimeUtc string, alertType string, limit *int32, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(minStartTimeUtc) > 0 { + queryParameters["startTimeUtc>"] = autorest.Encode("query", minStartTimeUtc) + } + if len(maxStartTimeUtc) > 0 { + queryParameters["startTimeUtc<"] = autorest.Encode("query", maxStartTimeUtc) + } + if len(alertType) > 0 { + queryParameters["alertType"] = autorest.Encode("query", alertType) + } + if limit != nil { + queryParameters["$limit"] = autorest.Encode("query", *limit) + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotAlerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client IotAlertsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client IotAlertsClient) ListResponder(resp *http.Response) (result IotAlertList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client IotAlertsClient) listNextResults(ctx context.Context, lastResults IotAlertList) (result IotAlertList, err error) { + req, err := lastResults.iotAlertListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.IotAlertsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.IotAlertsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotAlertsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotAlertsClient) ListComplete(ctx context.Context, resourceGroupName string, solutionName string, minStartTimeUtc string, maxStartTimeUtc string, alertType string, limit *int32, skipToken string) (result IotAlertListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotAlertsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, solutionName, minStartTimeUtc, maxStartTimeUtc, alertType, limit, skipToken) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotalerttypes.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotalerttypes.go new file mode 100644 index 0000000000000..808b7a24ecd25 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotalerttypes.go @@ -0,0 +1,217 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotAlertTypesClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type IotAlertTypesClient struct { + BaseClient +} + +// NewIotAlertTypesClient creates an instance of the IotAlertTypesClient client. +func NewIotAlertTypesClient(subscriptionID string, ascLocation string) IotAlertTypesClient { + return NewIotAlertTypesClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIotAlertTypesClientWithBaseURI creates an instance of the IotAlertTypesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewIotAlertTypesClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IotAlertTypesClient { + return IotAlertTypesClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get IoT alert type +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// iotAlertTypeName - name of the alert type +func (client IotAlertTypesClient) Get(ctx context.Context, resourceGroupName string, solutionName string, iotAlertTypeName string) (result IotAlertType, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotAlertTypesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotAlertTypesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, solutionName, iotAlertTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotAlertTypesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotAlertTypesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotAlertTypesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotAlertTypesClient) GetPreparer(ctx context.Context, resourceGroupName string, solutionName string, iotAlertTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotAlertTypeName": autorest.Encode("path", iotAlertTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotAlertTypes/{iotAlertTypeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotAlertTypesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotAlertTypesClient) GetResponder(resp *http.Response) (result IotAlertType, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list IoT alert types +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +func (client IotAlertTypesClient) List(ctx context.Context, resourceGroupName string, solutionName string) (result IotAlertTypeList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotAlertTypesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotAlertTypesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, solutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotAlertTypesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotAlertTypesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotAlertTypesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client IotAlertTypesClient) ListPreparer(ctx context.Context, resourceGroupName string, solutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotAlertTypes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client IotAlertTypesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client IotAlertTypesClient) ListResponder(resp *http.Response) (result IotAlertTypeList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotrecommendations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotrecommendations.go new file mode 100644 index 0000000000000..383e15b02e486 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotrecommendations.go @@ -0,0 +1,271 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotRecommendationsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type IotRecommendationsClient struct { + BaseClient +} + +// NewIotRecommendationsClient creates an instance of the IotRecommendationsClient client. +func NewIotRecommendationsClient(subscriptionID string, ascLocation string) IotRecommendationsClient { + return NewIotRecommendationsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIotRecommendationsClientWithBaseURI creates an instance of the IotRecommendationsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewIotRecommendationsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IotRecommendationsClient { + return IotRecommendationsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get IoT recommendation +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// iotRecommendationID - id of the recommendation +func (client IotRecommendationsClient) Get(ctx context.Context, resourceGroupName string, solutionName string, iotRecommendationID string) (result IotRecommendation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotRecommendationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotRecommendationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, solutionName, iotRecommendationID) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotRecommendationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotRecommendationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotRecommendationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotRecommendationsClient) GetPreparer(ctx context.Context, resourceGroupName string, solutionName string, iotRecommendationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotRecommendationId": autorest.Encode("path", iotRecommendationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotRecommendations/{iotRecommendationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotRecommendationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotRecommendationsClient) GetResponder(resp *http.Response) (result IotRecommendation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list IoT recommendations +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// recommendationType - filter by recommendation type +// limit - limit the number of items returned in a single page +// skipToken - skip token used for pagination +func (client IotRecommendationsClient) List(ctx context.Context, resourceGroupName string, solutionName string, recommendationType string, limit *int32, skipToken string) (result IotRecommendationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotRecommendationsClient.List") + defer func() { + sc := -1 + if result.irl.Response.Response != nil { + sc = result.irl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotRecommendationsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, solutionName, recommendationType, limit, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotRecommendationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.irl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotRecommendationsClient", "List", resp, "Failure sending request") + return + } + + result.irl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotRecommendationsClient", "List", resp, "Failure responding to request") + } + if result.irl.hasNextLink() && result.irl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client IotRecommendationsClient) ListPreparer(ctx context.Context, resourceGroupName string, solutionName string, recommendationType string, limit *int32, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(recommendationType) > 0 { + queryParameters["recommendationType"] = autorest.Encode("query", recommendationType) + } + if limit != nil { + queryParameters["$limit"] = autorest.Encode("query", *limit) + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotRecommendations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client IotRecommendationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client IotRecommendationsClient) ListResponder(resp *http.Response) (result IotRecommendationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client IotRecommendationsClient) listNextResults(ctx context.Context, lastResults IotRecommendationList) (result IotRecommendationList, err error) { + req, err := lastResults.iotRecommendationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.IotRecommendationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.IotRecommendationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotRecommendationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotRecommendationsClient) ListComplete(ctx context.Context, resourceGroupName string, solutionName string, recommendationType string, limit *int32, skipToken string) (result IotRecommendationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotRecommendationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, solutionName, recommendationType, limit, skipToken) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotrecommendationtypes.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotrecommendationtypes.go new file mode 100644 index 0000000000000..2737e3dfa7df7 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotrecommendationtypes.go @@ -0,0 +1,218 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotRecommendationTypesClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type IotRecommendationTypesClient struct { + BaseClient +} + +// NewIotRecommendationTypesClient creates an instance of the IotRecommendationTypesClient client. +func NewIotRecommendationTypesClient(subscriptionID string, ascLocation string) IotRecommendationTypesClient { + return NewIotRecommendationTypesClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIotRecommendationTypesClientWithBaseURI creates an instance of the IotRecommendationTypesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewIotRecommendationTypesClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IotRecommendationTypesClient { + return IotRecommendationTypesClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get IoT recommendation type +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// iotRecommendationTypeName - name of the recommendation type +func (client IotRecommendationTypesClient) Get(ctx context.Context, resourceGroupName string, solutionName string, iotRecommendationTypeName string) (result IotRecommendationType, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotRecommendationTypesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotRecommendationTypesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, solutionName, iotRecommendationTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotRecommendationTypesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotRecommendationTypesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotRecommendationTypesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotRecommendationTypesClient) GetPreparer(ctx context.Context, resourceGroupName string, solutionName string, iotRecommendationTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotRecommendationTypeName": autorest.Encode("path", iotRecommendationTypeName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotRecommendationTypes/{iotRecommendationTypeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotRecommendationTypesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotRecommendationTypesClient) GetResponder(resp *http.Response) (result IotRecommendationType, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list IoT recommendation types +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +func (client IotRecommendationTypesClient) List(ctx context.Context, resourceGroupName string, solutionName string) (result IotRecommendationTypeList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotRecommendationTypesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotRecommendationTypesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, solutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotRecommendationTypesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotRecommendationTypesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotRecommendationTypesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client IotRecommendationTypesClient) ListPreparer(ctx context.Context, resourceGroupName string, solutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/iotRecommendationTypes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client IotRecommendationTypesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client IotRecommendationTypesClient) ListResponder(resp *http.Response) (result IotRecommendationTypeList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolution.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolution.go new file mode 100644 index 0000000000000..a61324ccdf9f3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolution.go @@ -0,0 +1,657 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotSecuritySolutionClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type IotSecuritySolutionClient struct { + BaseClient +} + +// NewIotSecuritySolutionClient creates an instance of the IotSecuritySolutionClient client. +func NewIotSecuritySolutionClient(subscriptionID string, ascLocation string) IotSecuritySolutionClient { + return NewIotSecuritySolutionClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIotSecuritySolutionClientWithBaseURI creates an instance of the IotSecuritySolutionClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewIotSecuritySolutionClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IotSecuritySolutionClient { + return IotSecuritySolutionClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// CreateOrUpdate use this method to create or update yours IoT Security solution +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// iotSecuritySolutionData - the security solution data +func (client IotSecuritySolutionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, solutionName string, iotSecuritySolutionData IoTSecuritySolutionModel) (result IoTSecuritySolutionModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: iotSecuritySolutionData, + Constraints: []validation.Constraint{{Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties.DisplayName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties.IotHubs", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties.UserDefinedResources", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties.UserDefinedResources.Query", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotSecuritySolutionData.IoTSecuritySolutionProperties.UserDefinedResources.QuerySubscriptions", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, solutionName, iotSecuritySolutionData) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client IotSecuritySolutionClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, solutionName string, iotSecuritySolutionData IoTSecuritySolutionModel) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + iotSecuritySolutionData.ID = nil + iotSecuritySolutionData.Name = nil + iotSecuritySolutionData.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", pathParameters), + autorest.WithJSON(iotSecuritySolutionData), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionClient) CreateOrUpdateResponder(resp *http.Response) (result IoTSecuritySolutionModel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete use this method to delete yours IoT Security solution +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +func (client IotSecuritySolutionClient) Delete(ctx context.Context, resourceGroupName string, solutionName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, solutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client IotSecuritySolutionClient) DeletePreparer(ctx context.Context, resourceGroupName string, solutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get user this method to get details of a specific IoT Security solution based on solution name +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +func (client IotSecuritySolutionClient) Get(ctx context.Context, resourceGroupName string, solutionName string) (result IoTSecuritySolutionModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, solutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotSecuritySolutionClient) GetPreparer(ctx context.Context, resourceGroupName string, solutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionClient) GetResponder(resp *http.Response) (result IoTSecuritySolutionModel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup use this method to get the list IoT Security solutions organized by resource group. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// filter - filter the IoT Security solution with OData syntax. Supports filtering by iotHubs. +func (client IotSecuritySolutionClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result IoTSecuritySolutionsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.itssl.Response.Response != nil { + sc = result.itssl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.itssl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.itssl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.itssl.hasNextLink() && result.itssl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client IotSecuritySolutionClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionClient) ListByResourceGroupResponder(resp *http.Response) (result IoTSecuritySolutionsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client IotSecuritySolutionClient) listByResourceGroupNextResults(ctx context.Context, lastResults IoTSecuritySolutionsList) (result IoTSecuritySolutionsList, err error) { + req, err := lastResults.ioTSecuritySolutionsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotSecuritySolutionClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string) (result IoTSecuritySolutionsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter) + return +} + +// ListBySubscription use this method to get the list of IoT Security solutions by subscription. +// Parameters: +// filter - filter the IoT Security solution with OData syntax. Supports filtering by iotHubs. +func (client IotSecuritySolutionClient) ListBySubscription(ctx context.Context, filter string) (result IoTSecuritySolutionsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.ListBySubscription") + defer func() { + sc := -1 + if result.itssl.Response.Response != nil { + sc = result.itssl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.itssl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.itssl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "ListBySubscription", resp, "Failure responding to request") + } + if result.itssl.hasNextLink() && result.itssl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client IotSecuritySolutionClient) ListBySubscriptionPreparer(ctx context.Context, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/iotSecuritySolutions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionClient) ListBySubscriptionResponder(resp *http.Response) (result IoTSecuritySolutionsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client IotSecuritySolutionClient) listBySubscriptionNextResults(ctx context.Context, lastResults IoTSecuritySolutionsList) (result IoTSecuritySolutionsList, err error) { + req, err := lastResults.ioTSecuritySolutionsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotSecuritySolutionClient) ListBySubscriptionComplete(ctx context.Context, filter string) (result IoTSecuritySolutionsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx, filter) + return +} + +// Update use this method to update existing IoT Security solution tags or user defined resources. To update other +// fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// updateIotSecuritySolutionData - the security solution data +func (client IotSecuritySolutionClient) Update(ctx context.Context, resourceGroupName string, solutionName string, updateIotSecuritySolutionData UpdateIotSecuritySolutionData) (result IoTSecuritySolutionModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, solutionName, updateIotSecuritySolutionData) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client IotSecuritySolutionClient) UpdatePreparer(ctx context.Context, resourceGroupName string, solutionName string, updateIotSecuritySolutionData UpdateIotSecuritySolutionData) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}", pathParameters), + autorest.WithJSON(updateIotSecuritySolutionData), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionClient) UpdateResponder(resp *http.Response) (result IoTSecuritySolutionModel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionanalytics.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionanalytics.go new file mode 100644 index 0000000000000..9f537df7cab05 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionanalytics.go @@ -0,0 +1,216 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotSecuritySolutionAnalyticsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type IotSecuritySolutionAnalyticsClient struct { + BaseClient +} + +// NewIotSecuritySolutionAnalyticsClient creates an instance of the IotSecuritySolutionAnalyticsClient client. +func NewIotSecuritySolutionAnalyticsClient(subscriptionID string, ascLocation string) IotSecuritySolutionAnalyticsClient { + return NewIotSecuritySolutionAnalyticsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIotSecuritySolutionAnalyticsClientWithBaseURI creates an instance of the IotSecuritySolutionAnalyticsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewIotSecuritySolutionAnalyticsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IotSecuritySolutionAnalyticsClient { + return IotSecuritySolutionAnalyticsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get use this method to get IoT Security Analytics metrics. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +func (client IotSecuritySolutionAnalyticsClient) Get(ctx context.Context, resourceGroupName string, solutionName string) (result IoTSecuritySolutionAnalyticsModel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionAnalyticsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionAnalyticsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, solutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionAnalyticsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionAnalyticsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionAnalyticsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotSecuritySolutionAnalyticsClient) GetPreparer(ctx context.Context, resourceGroupName string, solutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionAnalyticsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionAnalyticsClient) GetResponder(resp *http.Response) (result IoTSecuritySolutionAnalyticsModel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List use this method to get IoT security Analytics metrics in an array. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +func (client IotSecuritySolutionAnalyticsClient) List(ctx context.Context, resourceGroupName string, solutionName string) (result IoTSecuritySolutionAnalyticsModelList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionAnalyticsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionAnalyticsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, solutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionAnalyticsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionAnalyticsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionAnalyticsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client IotSecuritySolutionAnalyticsClient) ListPreparer(ctx context.Context, resourceGroupName string, solutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionAnalyticsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionAnalyticsClient) ListResponder(resp *http.Response) (result IoTSecuritySolutionAnalyticsModelList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalert.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalert.go new file mode 100644 index 0000000000000..872a957953af7 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsaggregatedalert.go @@ -0,0 +1,353 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotSecuritySolutionsAnalyticsAggregatedAlertClient is the API spec for Microsoft.Security (Azure Security Center) +// resource provider +type IotSecuritySolutionsAnalyticsAggregatedAlertClient struct { + BaseClient +} + +// NewIotSecuritySolutionsAnalyticsAggregatedAlertClient creates an instance of the +// IotSecuritySolutionsAnalyticsAggregatedAlertClient client. +func NewIotSecuritySolutionsAnalyticsAggregatedAlertClient(subscriptionID string, ascLocation string) IotSecuritySolutionsAnalyticsAggregatedAlertClient { + return NewIotSecuritySolutionsAnalyticsAggregatedAlertClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIotSecuritySolutionsAnalyticsAggregatedAlertClientWithBaseURI creates an instance of the +// IotSecuritySolutionsAnalyticsAggregatedAlertClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewIotSecuritySolutionsAnalyticsAggregatedAlertClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IotSecuritySolutionsAnalyticsAggregatedAlertClient { + return IotSecuritySolutionsAnalyticsAggregatedAlertClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Dismiss use this method to dismiss an aggregated IoT Security Solution Alert. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// aggregatedAlertName - identifier of the aggregated alert. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) Dismiss(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionsAnalyticsAggregatedAlertClient.Dismiss") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "Dismiss", err.Error()) + } + + req, err := client.DismissPreparer(ctx, resourceGroupName, solutionName, aggregatedAlertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "Dismiss", nil, "Failure preparing request") + return + } + + resp, err := client.DismissSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "Dismiss", resp, "Failure sending request") + return + } + + result, err = client.DismissResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "Dismiss", resp, "Failure responding to request") + } + + return +} + +// DismissPreparer prepares the Dismiss request. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) DismissPreparer(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "aggregatedAlertName": autorest.Encode("path", aggregatedAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}/dismiss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DismissSender sends the Dismiss request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) DismissSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DismissResponder handles the response to the Dismiss request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) DismissResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get use this method to get a single the aggregated alert of yours IoT Security solution. This aggregation is +// performed by alert name. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// aggregatedAlertName - identifier of the aggregated alert. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) Get(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string) (result IoTSecurityAggregatedAlert, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionsAnalyticsAggregatedAlertClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, solutionName, aggregatedAlertName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) GetPreparer(ctx context.Context, resourceGroupName string, solutionName string, aggregatedAlertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "aggregatedAlertName": autorest.Encode("path", aggregatedAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) GetResponder(resp *http.Response) (result IoTSecurityAggregatedAlert, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List use this method to get the aggregated alert list of yours IoT Security solution. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// top - number of results to retrieve. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) List(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (result IoTSecurityAggregatedAlertListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionsAnalyticsAggregatedAlertClient.List") + defer func() { + sc := -1 + if result.itsaal.Response.Response != nil { + sc = result.itsaal.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, solutionName, top) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.itsaal.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "List", resp, "Failure sending request") + return + } + + result.itsaal, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "List", resp, "Failure responding to request") + } + if result.itsaal.hasNextLink() && result.itsaal.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) ListPreparer(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) ListResponder(resp *http.Response) (result IoTSecurityAggregatedAlertList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) listNextResults(ctx context.Context, lastResults IoTSecurityAggregatedAlertList) (result IoTSecurityAggregatedAlertList, err error) { + req, err := lastResults.ioTSecurityAggregatedAlertListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsAggregatedAlertClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotSecuritySolutionsAnalyticsAggregatedAlertClient) ListComplete(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (result IoTSecurityAggregatedAlertListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionsAnalyticsAggregatedAlertClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, solutionName, top) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendation.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendation.go new file mode 100644 index 0000000000000..e38412b4d9fbc --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/iotsecuritysolutionsanalyticsrecommendation.go @@ -0,0 +1,267 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotSecuritySolutionsAnalyticsRecommendationClient is the API spec for Microsoft.Security (Azure Security Center) +// resource provider +type IotSecuritySolutionsAnalyticsRecommendationClient struct { + BaseClient +} + +// NewIotSecuritySolutionsAnalyticsRecommendationClient creates an instance of the +// IotSecuritySolutionsAnalyticsRecommendationClient client. +func NewIotSecuritySolutionsAnalyticsRecommendationClient(subscriptionID string, ascLocation string) IotSecuritySolutionsAnalyticsRecommendationClient { + return NewIotSecuritySolutionsAnalyticsRecommendationClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewIotSecuritySolutionsAnalyticsRecommendationClientWithBaseURI creates an instance of the +// IotSecuritySolutionsAnalyticsRecommendationClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewIotSecuritySolutionsAnalyticsRecommendationClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) IotSecuritySolutionsAnalyticsRecommendationClient { + return IotSecuritySolutionsAnalyticsRecommendationClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get use this method to get the aggregated security analytics recommendation of yours IoT Security solution. This +// aggregation is performed by recommendation name. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// aggregatedRecommendationName - name of the recommendation aggregated for this query. +func (client IotSecuritySolutionsAnalyticsRecommendationClient) Get(ctx context.Context, resourceGroupName string, solutionName string, aggregatedRecommendationName string) (result IoTSecurityAggregatedRecommendation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionsAnalyticsRecommendationClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionsAnalyticsRecommendationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, solutionName, aggregatedRecommendationName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsRecommendationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsRecommendationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsRecommendationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotSecuritySolutionsAnalyticsRecommendationClient) GetPreparer(ctx context.Context, resourceGroupName string, solutionName string, aggregatedRecommendationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "aggregatedRecommendationName": autorest.Encode("path", aggregatedRecommendationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations/{aggregatedRecommendationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionsAnalyticsRecommendationClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionsAnalyticsRecommendationClient) GetResponder(resp *http.Response) (result IoTSecurityAggregatedRecommendation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List use this method to get the list of aggregated security analytics recommendations of yours IoT Security +// solution. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// solutionName - the name of the IoT Security solution. +// top - number of results to retrieve. +func (client IotSecuritySolutionsAnalyticsRecommendationClient) List(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (result IoTSecurityAggregatedRecommendationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionsAnalyticsRecommendationClient.List") + defer func() { + sc := -1 + if result.itsarl.Response.Response != nil { + sc = result.itsarl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.IotSecuritySolutionsAnalyticsRecommendationClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, solutionName, top) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsRecommendationClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.itsarl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsRecommendationClient", "List", resp, "Failure sending request") + return + } + + result.itsarl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsRecommendationClient", "List", resp, "Failure responding to request") + } + if result.itsarl.hasNextLink() && result.itsarl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client IotSecuritySolutionsAnalyticsRecommendationClient) ListPreparer(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "solutionName": autorest.Encode("path", solutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client IotSecuritySolutionsAnalyticsRecommendationClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client IotSecuritySolutionsAnalyticsRecommendationClient) ListResponder(resp *http.Response) (result IoTSecurityAggregatedRecommendationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client IotSecuritySolutionsAnalyticsRecommendationClient) listNextResults(ctx context.Context, lastResults IoTSecurityAggregatedRecommendationList) (result IoTSecurityAggregatedRecommendationList, err error) { + req, err := lastResults.ioTSecurityAggregatedRecommendationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsRecommendationClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsRecommendationClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.IotSecuritySolutionsAnalyticsRecommendationClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotSecuritySolutionsAnalyticsRecommendationClient) ListComplete(ctx context.Context, resourceGroupName string, solutionName string, top *int32) (result IoTSecurityAggregatedRecommendationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotSecuritySolutionsAnalyticsRecommendationClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, solutionName, top) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/jitnetworkaccesspolicies.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/jitnetworkaccesspolicies.go new file mode 100644 index 0000000000000..b0dfcb15030f8 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/jitnetworkaccesspolicies.go @@ -0,0 +1,893 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// JitNetworkAccessPoliciesClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type JitNetworkAccessPoliciesClient struct { + BaseClient +} + +// NewJitNetworkAccessPoliciesClient creates an instance of the JitNetworkAccessPoliciesClient client. +func NewJitNetworkAccessPoliciesClient(subscriptionID string, ascLocation string) JitNetworkAccessPoliciesClient { + return NewJitNetworkAccessPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewJitNetworkAccessPoliciesClientWithBaseURI creates an instance of the JitNetworkAccessPoliciesClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewJitNetworkAccessPoliciesClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) JitNetworkAccessPoliciesClient { + return JitNetworkAccessPoliciesClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// CreateOrUpdate create a policy for protecting resources using Just-in-Time access control +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// jitNetworkAccessPolicyName - name of a Just-in-Time access configuration policy. +func (client JitNetworkAccessPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, jitNetworkAccessPolicyName string, body JitNetworkAccessPolicy) (result JitNetworkAccessPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.JitNetworkAccessPolicyProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "body.JitNetworkAccessPolicyProperties.VirtualMachines", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("security.JitNetworkAccessPoliciesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, jitNetworkAccessPolicyName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JitNetworkAccessPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, jitNetworkAccessPolicyName string, body JitNetworkAccessPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "jitNetworkAccessPolicyName": autorest.Encode("path", jitNetworkAccessPolicyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + body.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JitNetworkAccessPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JitNetworkAccessPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result JitNetworkAccessPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a Just-in-Time access control policy. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// jitNetworkAccessPolicyName - name of a Just-in-Time access configuration policy. +func (client JitNetworkAccessPoliciesClient) Delete(ctx context.Context, resourceGroupName string, jitNetworkAccessPolicyName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.JitNetworkAccessPoliciesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, jitNetworkAccessPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JitNetworkAccessPoliciesClient) DeletePreparer(ctx context.Context, resourceGroupName string, jitNetworkAccessPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "jitNetworkAccessPolicyName": autorest.Encode("path", jitNetworkAccessPolicyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JitNetworkAccessPoliciesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JitNetworkAccessPoliciesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get policies for protecting resources using Just-in-Time access control for the subscription, location +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// jitNetworkAccessPolicyName - name of a Just-in-Time access configuration policy. +func (client JitNetworkAccessPoliciesClient) Get(ctx context.Context, resourceGroupName string, jitNetworkAccessPolicyName string) (result JitNetworkAccessPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.JitNetworkAccessPoliciesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, jitNetworkAccessPolicyName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JitNetworkAccessPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, jitNetworkAccessPolicyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "jitNetworkAccessPolicyName": autorest.Encode("path", jitNetworkAccessPolicyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JitNetworkAccessPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JitNetworkAccessPoliciesClient) GetResponder(resp *http.Response) (result JitNetworkAccessPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Initiate initiate a JIT access from a specific Just-in-Time policy configuration. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// jitNetworkAccessPolicyName - name of a Just-in-Time access configuration policy. +func (client JitNetworkAccessPoliciesClient) Initiate(ctx context.Context, resourceGroupName string, jitNetworkAccessPolicyName string, body JitNetworkAccessPolicyInitiateRequest) (result JitNetworkAccessRequest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.Initiate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body.VirtualMachines", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.JitNetworkAccessPoliciesClient", "Initiate", err.Error()) + } + + req, err := client.InitiatePreparer(ctx, resourceGroupName, jitNetworkAccessPolicyName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "Initiate", nil, "Failure preparing request") + return + } + + resp, err := client.InitiateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "Initiate", resp, "Failure sending request") + return + } + + result, err = client.InitiateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "Initiate", resp, "Failure responding to request") + } + + return +} + +// InitiatePreparer prepares the Initiate request. +func (client JitNetworkAccessPoliciesClient) InitiatePreparer(ctx context.Context, resourceGroupName string, jitNetworkAccessPolicyName string, body JitNetworkAccessPolicyInitiateRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "jitNetworkAccessPolicyInitiateType": autorest.Encode("path", "initiate"), + "jitNetworkAccessPolicyName": autorest.Encode("path", jitNetworkAccessPolicyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}/{jitNetworkAccessPolicyInitiateType}", pathParameters), + autorest.WithJSON(body), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// InitiateSender sends the Initiate request. The method will close the +// http.Response Body if it receives an error. +func (client JitNetworkAccessPoliciesClient) InitiateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// InitiateResponder handles the response to the Initiate request. The method always +// closes the http.Response Body. +func (client JitNetworkAccessPoliciesClient) InitiateResponder(resp *http.Response) (result JitNetworkAccessRequest, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List policies for protecting resources using Just-in-Time access control. +func (client JitNetworkAccessPoliciesClient) List(ctx context.Context) (result JitNetworkAccessPoliciesListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.List") + defer func() { + sc := -1 + if result.jnapl.Response.Response != nil { + sc = result.jnapl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.JitNetworkAccessPoliciesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.jnapl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "List", resp, "Failure sending request") + return + } + + result.jnapl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "List", resp, "Failure responding to request") + } + if result.jnapl.hasNextLink() && result.jnapl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client JitNetworkAccessPoliciesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/jitNetworkAccessPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client JitNetworkAccessPoliciesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client JitNetworkAccessPoliciesClient) ListResponder(resp *http.Response) (result JitNetworkAccessPoliciesList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client JitNetworkAccessPoliciesClient) listNextResults(ctx context.Context, lastResults JitNetworkAccessPoliciesList) (result JitNetworkAccessPoliciesList, err error) { + req, err := lastResults.jitNetworkAccessPoliciesListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client JitNetworkAccessPoliciesClient) ListComplete(ctx context.Context) (result JitNetworkAccessPoliciesListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByRegion policies for protecting resources using Just-in-Time access control for the subscription, location +func (client JitNetworkAccessPoliciesClient) ListByRegion(ctx context.Context) (result JitNetworkAccessPoliciesListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.ListByRegion") + defer func() { + sc := -1 + if result.jnapl.Response.Response != nil { + sc = result.jnapl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.JitNetworkAccessPoliciesClient", "ListByRegion", err.Error()) + } + + result.fn = client.listByRegionNextResults + req, err := client.ListByRegionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "ListByRegion", nil, "Failure preparing request") + return + } + + resp, err := client.ListByRegionSender(req) + if err != nil { + result.jnapl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "ListByRegion", resp, "Failure sending request") + return + } + + result.jnapl, err = client.ListByRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "ListByRegion", resp, "Failure responding to request") + } + if result.jnapl.hasNextLink() && result.jnapl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByRegionPreparer prepares the ListByRegion request. +func (client JitNetworkAccessPoliciesClient) ListByRegionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByRegionSender sends the ListByRegion request. The method will close the +// http.Response Body if it receives an error. +func (client JitNetworkAccessPoliciesClient) ListByRegionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByRegionResponder handles the response to the ListByRegion request. The method always +// closes the http.Response Body. +func (client JitNetworkAccessPoliciesClient) ListByRegionResponder(resp *http.Response) (result JitNetworkAccessPoliciesList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByRegionNextResults retrieves the next set of results, if any. +func (client JitNetworkAccessPoliciesClient) listByRegionNextResults(ctx context.Context, lastResults JitNetworkAccessPoliciesList) (result JitNetworkAccessPoliciesList, err error) { + req, err := lastResults.jitNetworkAccessPoliciesListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listByRegionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByRegionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listByRegionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listByRegionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByRegionComplete enumerates all values, automatically crossing page boundaries as required. +func (client JitNetworkAccessPoliciesClient) ListByRegionComplete(ctx context.Context) (result JitNetworkAccessPoliciesListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.ListByRegion") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByRegion(ctx) + return +} + +// ListByResourceGroup policies for protecting resources using Just-in-Time access control for the subscription, +// location +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client JitNetworkAccessPoliciesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result JitNetworkAccessPoliciesListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.jnapl.Response.Response != nil { + sc = result.jnapl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.JitNetworkAccessPoliciesClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.jnapl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.jnapl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.jnapl.hasNextLink() && result.jnapl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client JitNetworkAccessPoliciesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/jitNetworkAccessPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client JitNetworkAccessPoliciesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client JitNetworkAccessPoliciesClient) ListByResourceGroupResponder(resp *http.Response) (result JitNetworkAccessPoliciesList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client JitNetworkAccessPoliciesClient) listByResourceGroupNextResults(ctx context.Context, lastResults JitNetworkAccessPoliciesList) (result JitNetworkAccessPoliciesList, err error) { + req, err := lastResults.jitNetworkAccessPoliciesListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client JitNetworkAccessPoliciesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result JitNetworkAccessPoliciesListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListByResourceGroupAndRegion policies for protecting resources using Just-in-Time access control for the +// subscription, location +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +func (client JitNetworkAccessPoliciesClient) ListByResourceGroupAndRegion(ctx context.Context, resourceGroupName string) (result JitNetworkAccessPoliciesListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.ListByResourceGroupAndRegion") + defer func() { + sc := -1 + if result.jnapl.Response.Response != nil { + sc = result.jnapl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.JitNetworkAccessPoliciesClient", "ListByResourceGroupAndRegion", err.Error()) + } + + result.fn = client.listByResourceGroupAndRegionNextResults + req, err := client.ListByResourceGroupAndRegionPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "ListByResourceGroupAndRegion", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupAndRegionSender(req) + if err != nil { + result.jnapl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "ListByResourceGroupAndRegion", resp, "Failure sending request") + return + } + + result.jnapl, err = client.ListByResourceGroupAndRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "ListByResourceGroupAndRegion", resp, "Failure responding to request") + } + if result.jnapl.hasNextLink() && result.jnapl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupAndRegionPreparer prepares the ListByResourceGroupAndRegion request. +func (client JitNetworkAccessPoliciesClient) ListByResourceGroupAndRegionPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupAndRegionSender sends the ListByResourceGroupAndRegion request. The method will close the +// http.Response Body if it receives an error. +func (client JitNetworkAccessPoliciesClient) ListByResourceGroupAndRegionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupAndRegionResponder handles the response to the ListByResourceGroupAndRegion request. The method always +// closes the http.Response Body. +func (client JitNetworkAccessPoliciesClient) ListByResourceGroupAndRegionResponder(resp *http.Response) (result JitNetworkAccessPoliciesList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupAndRegionNextResults retrieves the next set of results, if any. +func (client JitNetworkAccessPoliciesClient) listByResourceGroupAndRegionNextResults(ctx context.Context, lastResults JitNetworkAccessPoliciesList) (result JitNetworkAccessPoliciesList, err error) { + req, err := lastResults.jitNetworkAccessPoliciesListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listByResourceGroupAndRegionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupAndRegionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listByResourceGroupAndRegionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupAndRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.JitNetworkAccessPoliciesClient", "listByResourceGroupAndRegionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupAndRegionComplete enumerates all values, automatically crossing page boundaries as required. +func (client JitNetworkAccessPoliciesClient) ListByResourceGroupAndRegionComplete(ctx context.Context, resourceGroupName string) (result JitNetworkAccessPoliciesListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesClient.ListByResourceGroupAndRegion") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupAndRegion(ctx, resourceGroupName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/locations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/locations.go new file mode 100644 index 0000000000000..cccea770f7167 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/locations.go @@ -0,0 +1,239 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// LocationsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type LocationsClient struct { + BaseClient +} + +// NewLocationsClient creates an instance of the LocationsClient client. +func NewLocationsClient(subscriptionID string, ascLocation string) LocationsClient { + return NewLocationsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewLocationsClientWithBaseURI creates an instance of the LocationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewLocationsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) LocationsClient { + return LocationsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get details of a specific location +func (client LocationsClient) Get(ctx context.Context) (result AscLocation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.LocationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.LocationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.LocationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.LocationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LocationsClient) GetPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LocationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LocationsClient) GetResponder(resp *http.Response) (result AscLocation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List the location of the responsible ASC of the specific subscription (home region). For each subscription there is +// only one responsible location. The location in the response should be used to read or write other resources in ASC +// according to their ID. +func (client LocationsClient) List(ctx context.Context) (result AscLocationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.List") + defer func() { + sc := -1 + if result.all.Response.Response != nil { + sc = result.all.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.LocationsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.LocationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.all.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.LocationsClient", "List", resp, "Failure sending request") + return + } + + result.all, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.LocationsClient", "List", resp, "Failure responding to request") + } + if result.all.hasNextLink() && result.all.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client LocationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client LocationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LocationsClient) ListResponder(resp *http.Response) (result AscLocationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client LocationsClient) listNextResults(ctx context.Context, lastResults AscLocationList) (result AscLocationList, err error) { + req, err := lastResults.ascLocationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.LocationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.LocationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.LocationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client LocationsClient) ListComplete(ctx context.Context) (result AscLocationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/models.go new file mode 100644 index 0000000000000..852b77af86fd2 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/models.go @@ -0,0 +1,18649 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security" + +// AadConnectivityState1 describes an Azure resource with kind +type AadConnectivityState1 struct { + // ConnectivityState - Possible values include: 'Discovered', 'NotLicensed', 'Connected' + ConnectivityState AadConnectivityState `json:"connectivityState,omitempty"` +} + +// AadExternalSecuritySolution represents an AAD identity protection solution which sends logs to an OMS +// workspace. +type AadExternalSecuritySolution struct { + Properties *AadSolutionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + // Kind - Possible values include: 'KindExternalSecuritySolution', 'KindCEF', 'KindATA', 'KindAAD' + Kind KindEnum1 `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for AadExternalSecuritySolution. +func (aess AadExternalSecuritySolution) MarshalJSON() ([]byte, error) { + aess.Kind = KindAAD + objectMap := make(map[string]interface{}) + if aess.Properties != nil { + objectMap["properties"] = aess.Properties + } + if aess.Kind != "" { + objectMap["kind"] = aess.Kind + } + return json.Marshal(objectMap) +} + +// AsCefExternalSecuritySolution is the BasicExternalSecuritySolution implementation for AadExternalSecuritySolution. +func (aess AadExternalSecuritySolution) AsCefExternalSecuritySolution() (*CefExternalSecuritySolution, bool) { + return nil, false +} + +// AsAtaExternalSecuritySolution is the BasicExternalSecuritySolution implementation for AadExternalSecuritySolution. +func (aess AadExternalSecuritySolution) AsAtaExternalSecuritySolution() (*AtaExternalSecuritySolution, bool) { + return nil, false +} + +// AsAadExternalSecuritySolution is the BasicExternalSecuritySolution implementation for AadExternalSecuritySolution. +func (aess AadExternalSecuritySolution) AsAadExternalSecuritySolution() (*AadExternalSecuritySolution, bool) { + return &aess, true +} + +// AsExternalSecuritySolution is the BasicExternalSecuritySolution implementation for AadExternalSecuritySolution. +func (aess AadExternalSecuritySolution) AsExternalSecuritySolution() (*ExternalSecuritySolution, bool) { + return nil, false +} + +// AsBasicExternalSecuritySolution is the BasicExternalSecuritySolution implementation for AadExternalSecuritySolution. +func (aess AadExternalSecuritySolution) AsBasicExternalSecuritySolution() (BasicExternalSecuritySolution, bool) { + return &aess, true +} + +// AadSolutionProperties ... +type AadSolutionProperties struct { + DeviceVendor *string `json:"deviceVendor,omitempty"` + DeviceType *string `json:"deviceType,omitempty"` + Workspace *ConnectedWorkspace `json:"workspace,omitempty"` + // ConnectivityState - Possible values include: 'Discovered', 'NotLicensed', 'Connected' + ConnectivityState AadConnectivityState `json:"connectivityState,omitempty"` +} + +// ActiveConnectionsNotInAllowedRange number of active connections is not in allowed range. +type ActiveConnectionsNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) MarshalJSON() ([]byte, error) { + acniar.RuleType = RuleTypeActiveConnectionsNotInAllowedRange + objectMap := make(map[string]interface{}) + if acniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = acniar.TimeWindowSize + } + if acniar.MinThreshold != nil { + objectMap["minThreshold"] = acniar.MinThreshold + } + if acniar.MaxThreshold != nil { + objectMap["maxThreshold"] = acniar.MaxThreshold + } + if acniar.IsEnabled != nil { + objectMap["isEnabled"] = acniar.IsEnabled + } + if acniar.RuleType != "" { + objectMap["ruleType"] = acniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &acniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &acniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return &acniar, true +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for ActiveConnectionsNotInAllowedRange. +func (acniar ActiveConnectionsNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &acniar, true +} + +// AdaptiveApplicationControlGroup ... +type AdaptiveApplicationControlGroup struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + *AdaptiveApplicationControlGroupData `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdaptiveApplicationControlGroup. +func (aacg AdaptiveApplicationControlGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aacg.AdaptiveApplicationControlGroupData != nil { + objectMap["properties"] = aacg.AdaptiveApplicationControlGroupData + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AdaptiveApplicationControlGroup struct. +func (aacg *AdaptiveApplicationControlGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + aacg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + aacg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + aacg.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + aacg.Location = &location + } + case "properties": + if v != nil { + var adaptiveApplicationControlGroupData AdaptiveApplicationControlGroupData + err = json.Unmarshal(*v, &adaptiveApplicationControlGroupData) + if err != nil { + return err + } + aacg.AdaptiveApplicationControlGroupData = &adaptiveApplicationControlGroupData + } + } + } + + return nil +} + +// AdaptiveApplicationControlGroupData represents a machines group and set of rules to be allowed running on a +// machine +type AdaptiveApplicationControlGroupData struct { + // EnforcementMode - Possible values include: 'Audit', 'Enforce', 'None' + EnforcementMode EnforcementMode `json:"enforcementMode,omitempty"` + ProtectionMode *ProtectionMode `json:"protectionMode,omitempty"` + // ConfigurationStatus - READ-ONLY; Possible values include: 'ConfigurationStatus2Configured', 'ConfigurationStatus2NotConfigured', 'ConfigurationStatus2InProgress', 'ConfigurationStatus2Failed', 'ConfigurationStatus2NoStatus' + ConfigurationStatus ConfigurationStatus2 `json:"configurationStatus,omitempty"` + // RecommendationStatus - READ-ONLY; Possible values include: 'RecommendationStatusRecommended', 'RecommendationStatusNotRecommended', 'RecommendationStatusNotAvailable', 'RecommendationStatusNoStatus' + RecommendationStatus RecommendationStatus `json:"recommendationStatus,omitempty"` + // Issues - READ-ONLY + Issues *[]AdaptiveApplicationControlIssueSummary `json:"issues,omitempty"` + // SourceSystem - READ-ONLY; Possible values include: 'SourceSystemAzureAppLocker', 'SourceSystemAzureAuditD', 'SourceSystemNonAzureAppLocker', 'SourceSystemNonAzureAuditD', 'SourceSystemNone' + SourceSystem SourceSystem `json:"sourceSystem,omitempty"` + VMRecommendations *[]VMRecommendation `json:"vmRecommendations,omitempty"` + PathRecommendations *[]PathRecommendation `json:"pathRecommendations,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdaptiveApplicationControlGroupData. +func (aacgd AdaptiveApplicationControlGroupData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aacgd.EnforcementMode != "" { + objectMap["enforcementMode"] = aacgd.EnforcementMode + } + if aacgd.ProtectionMode != nil { + objectMap["protectionMode"] = aacgd.ProtectionMode + } + if aacgd.VMRecommendations != nil { + objectMap["vmRecommendations"] = aacgd.VMRecommendations + } + if aacgd.PathRecommendations != nil { + objectMap["pathRecommendations"] = aacgd.PathRecommendations + } + return json.Marshal(objectMap) +} + +// AdaptiveApplicationControlGroups represents a list of machine groups and set of rules that are recommended +// by Azure Security Center to be allowed +type AdaptiveApplicationControlGroups struct { + autorest.Response `json:"-"` + Value *[]AdaptiveApplicationControlGroup `json:"value,omitempty"` +} + +// AdaptiveApplicationControlIssueSummary represents a summary of the alerts of the machine group +type AdaptiveApplicationControlIssueSummary struct { + // Issue - Possible values include: 'ViolationsAudited', 'ViolationsBlocked', 'MsiAndScriptViolationsAudited', 'MsiAndScriptViolationsBlocked', 'ExecutableViolationsAudited', 'RulesViolatedManually' + Issue Issue `json:"issue,omitempty"` + // NumberOfVms - The number of machines in the group that have this alert + NumberOfVms *float64 `json:"numberOfVms,omitempty"` +} + +// AdaptiveNetworkHardening the resource whose properties describes the Adaptive Network Hardening settings for +// some Azure resource +type AdaptiveNetworkHardening struct { + autorest.Response `json:"-"` + // AdaptiveNetworkHardeningProperties - Properties of the Adaptive Network Hardening resource + *AdaptiveNetworkHardeningProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdaptiveNetworkHardening. +func (anh AdaptiveNetworkHardening) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if anh.AdaptiveNetworkHardeningProperties != nil { + objectMap["properties"] = anh.AdaptiveNetworkHardeningProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AdaptiveNetworkHardening struct. +func (anh *AdaptiveNetworkHardening) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var adaptiveNetworkHardeningProperties AdaptiveNetworkHardeningProperties + err = json.Unmarshal(*v, &adaptiveNetworkHardeningProperties) + if err != nil { + return err + } + anh.AdaptiveNetworkHardeningProperties = &adaptiveNetworkHardeningProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + anh.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + anh.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + anh.Type = &typeVar + } + } + } + + return nil +} + +// AdaptiveNetworkHardeningEnforceRequest ... +type AdaptiveNetworkHardeningEnforceRequest struct { + // Rules - The rules to enforce + Rules *[]Rule `json:"rules,omitempty"` + // NetworkSecurityGroups - The Azure resource IDs of the effective network security groups that will be updated with the created security rules from the Adaptive Network Hardening rules + NetworkSecurityGroups *[]string `json:"networkSecurityGroups,omitempty"` +} + +// AdaptiveNetworkHardeningProperties adaptive Network Hardening resource properties +type AdaptiveNetworkHardeningProperties struct { + // Rules - The security rules which are recommended to be effective on the VM + Rules *[]Rule `json:"rules,omitempty"` + // RulesCalculationTime - The UTC time on which the rules were calculated + RulesCalculationTime *date.Time `json:"rulesCalculationTime,omitempty"` + // EffectiveNetworkSecurityGroups - The Network Security Groups effective on the network interfaces of the protected resource + EffectiveNetworkSecurityGroups *[]EffectiveNetworkSecurityGroups `json:"effectiveNetworkSecurityGroups,omitempty"` +} + +// AdaptiveNetworkHardeningsEnforceFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type AdaptiveNetworkHardeningsEnforceFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AdaptiveNetworkHardeningsEnforceFuture) Result(client AdaptiveNetworkHardeningsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "security.AdaptiveNetworkHardeningsEnforceFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("security.AdaptiveNetworkHardeningsEnforceFuture") + return + } + ar.Response = future.Response() + return +} + +// AdaptiveNetworkHardeningsList response for ListAdaptiveNetworkHardenings API service call +type AdaptiveNetworkHardeningsList struct { + autorest.Response `json:"-"` + // Value - A list of Adaptive Network Hardenings resources + Value *[]AdaptiveNetworkHardening `json:"value,omitempty"` + // NextLink - The URL to get the next set of results + NextLink *string `json:"nextLink,omitempty"` +} + +// AdaptiveNetworkHardeningsListIterator provides access to a complete listing of AdaptiveNetworkHardening +// values. +type AdaptiveNetworkHardeningsListIterator struct { + i int + page AdaptiveNetworkHardeningsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AdaptiveNetworkHardeningsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AdaptiveNetworkHardeningsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AdaptiveNetworkHardeningsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AdaptiveNetworkHardeningsListIterator) Response() AdaptiveNetworkHardeningsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AdaptiveNetworkHardeningsListIterator) Value() AdaptiveNetworkHardening { + if !iter.page.NotDone() { + return AdaptiveNetworkHardening{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AdaptiveNetworkHardeningsListIterator type. +func NewAdaptiveNetworkHardeningsListIterator(page AdaptiveNetworkHardeningsListPage) AdaptiveNetworkHardeningsListIterator { + return AdaptiveNetworkHardeningsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (anhl AdaptiveNetworkHardeningsList) IsEmpty() bool { + return anhl.Value == nil || len(*anhl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (anhl AdaptiveNetworkHardeningsList) hasNextLink() bool { + return anhl.NextLink != nil && len(*anhl.NextLink) != 0 +} + +// adaptiveNetworkHardeningsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (anhl AdaptiveNetworkHardeningsList) adaptiveNetworkHardeningsListPreparer(ctx context.Context) (*http.Request, error) { + if !anhl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(anhl.NextLink))) +} + +// AdaptiveNetworkHardeningsListPage contains a page of AdaptiveNetworkHardening values. +type AdaptiveNetworkHardeningsListPage struct { + fn func(context.Context, AdaptiveNetworkHardeningsList) (AdaptiveNetworkHardeningsList, error) + anhl AdaptiveNetworkHardeningsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AdaptiveNetworkHardeningsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdaptiveNetworkHardeningsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.anhl) + if err != nil { + return err + } + page.anhl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AdaptiveNetworkHardeningsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AdaptiveNetworkHardeningsListPage) NotDone() bool { + return !page.anhl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AdaptiveNetworkHardeningsListPage) Response() AdaptiveNetworkHardeningsList { + return page.anhl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AdaptiveNetworkHardeningsListPage) Values() []AdaptiveNetworkHardening { + if page.anhl.IsEmpty() { + return nil + } + return *page.anhl.Value +} + +// Creates a new instance of the AdaptiveNetworkHardeningsListPage type. +func NewAdaptiveNetworkHardeningsListPage(getNextPage func(context.Context, AdaptiveNetworkHardeningsList) (AdaptiveNetworkHardeningsList, error)) AdaptiveNetworkHardeningsListPage { + return AdaptiveNetworkHardeningsListPage{fn: getNextPage} +} + +// BasicAdditionalData details of the sub-assessment +type BasicAdditionalData interface { + AsSQLServerVulnerabilityProperties() (*SQLServerVulnerabilityProperties, bool) + AsContainerRegistryVulnerabilityProperties() (*ContainerRegistryVulnerabilityProperties, bool) + AsServerVulnerabilityProperties() (*ServerVulnerabilityProperties, bool) + AsAdditionalData() (*AdditionalData, bool) +} + +// AdditionalData details of the sub-assessment +type AdditionalData struct { + // AssessedResourceType - Possible values include: 'AssessedResourceTypeAdditionalData', 'AssessedResourceTypeSQLServerVulnerability', 'AssessedResourceTypeContainerRegistryVulnerability', 'AssessedResourceTypeServerVulnerabilityAssessment' + AssessedResourceType AssessedResourceType `json:"assessedResourceType,omitempty"` +} + +func unmarshalBasicAdditionalData(body []byte) (BasicAdditionalData, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["assessedResourceType"] { + case string(AssessedResourceTypeSQLServerVulnerability): + var ssvp SQLServerVulnerabilityProperties + err := json.Unmarshal(body, &ssvp) + return ssvp, err + case string(AssessedResourceTypeContainerRegistryVulnerability): + var crvp ContainerRegistryVulnerabilityProperties + err := json.Unmarshal(body, &crvp) + return crvp, err + case string(AssessedResourceTypeServerVulnerabilityAssessment): + var svp ServerVulnerabilityProperties + err := json.Unmarshal(body, &svp) + return svp, err + default: + var ad AdditionalData + err := json.Unmarshal(body, &ad) + return ad, err + } +} +func unmarshalBasicAdditionalDataArray(body []byte) ([]BasicAdditionalData, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + adArray := make([]BasicAdditionalData, len(rawMessages)) + + for index, rawMessage := range rawMessages { + ad, err := unmarshalBasicAdditionalData(*rawMessage) + if err != nil { + return nil, err + } + adArray[index] = ad + } + return adArray, nil +} + +// MarshalJSON is the custom marshaler for AdditionalData. +func (ad AdditionalData) MarshalJSON() ([]byte, error) { + ad.AssessedResourceType = AssessedResourceTypeAdditionalData + objectMap := make(map[string]interface{}) + if ad.AssessedResourceType != "" { + objectMap["assessedResourceType"] = ad.AssessedResourceType + } + return json.Marshal(objectMap) +} + +// AsSQLServerVulnerabilityProperties is the BasicAdditionalData implementation for AdditionalData. +func (ad AdditionalData) AsSQLServerVulnerabilityProperties() (*SQLServerVulnerabilityProperties, bool) { + return nil, false +} + +// AsContainerRegistryVulnerabilityProperties is the BasicAdditionalData implementation for AdditionalData. +func (ad AdditionalData) AsContainerRegistryVulnerabilityProperties() (*ContainerRegistryVulnerabilityProperties, bool) { + return nil, false +} + +// AsServerVulnerabilityProperties is the BasicAdditionalData implementation for AdditionalData. +func (ad AdditionalData) AsServerVulnerabilityProperties() (*ServerVulnerabilityProperties, bool) { + return nil, false +} + +// AsAdditionalData is the BasicAdditionalData implementation for AdditionalData. +func (ad AdditionalData) AsAdditionalData() (*AdditionalData, bool) { + return &ad, true +} + +// AsBasicAdditionalData is the BasicAdditionalData implementation for AdditionalData. +func (ad AdditionalData) AsBasicAdditionalData() (BasicAdditionalData, bool) { + return &ad, true +} + +// AdvancedThreatProtectionProperties the Advanced Threat Protection settings. +type AdvancedThreatProtectionProperties struct { + // IsEnabled - Indicates whether Advanced Threat Protection is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` +} + +// AdvancedThreatProtectionSetting the Advanced Threat Protection resource. +type AdvancedThreatProtectionSetting struct { + autorest.Response `json:"-"` + *AdvancedThreatProtectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdvancedThreatProtectionSetting. +func (atps AdvancedThreatProtectionSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if atps.AdvancedThreatProtectionProperties != nil { + objectMap["properties"] = atps.AdvancedThreatProtectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AdvancedThreatProtectionSetting struct. +func (atps *AdvancedThreatProtectionSetting) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var advancedThreatProtectionProperties AdvancedThreatProtectionProperties + err = json.Unmarshal(*v, &advancedThreatProtectionProperties) + if err != nil { + return err + } + atps.AdvancedThreatProtectionProperties = &advancedThreatProtectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + atps.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + atps.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + atps.Type = &typeVar + } + } + } + + return nil +} + +// Alert security alert +type Alert struct { + autorest.Response `json:"-"` + *AlertProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Alert. +func (a Alert) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AlertProperties != nil { + objectMap["properties"] = a.AlertProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Alert struct. +func (a *Alert) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var alertProperties AlertProperties + err = json.Unmarshal(*v, &alertProperties) + if err != nil { + return err + } + a.AlertProperties = &alertProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// AlertConfidenceReason factors that increase our confidence that the alert is a true positive +type AlertConfidenceReason struct { + // Type - READ-ONLY; Type of confidence factor + Type *string `json:"type,omitempty"` + // Reason - READ-ONLY; description of the confidence reason + Reason *string `json:"reason,omitempty"` +} + +// AlertEntity changing set of properties depending on the entity type. +type AlertEntity struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Type - READ-ONLY; Type of entity + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertEntity. +func (ae AlertEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + for k, v := range ae.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AlertEntity struct. +func (ae *AlertEntity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if ae.AdditionalProperties == nil { + ae.AdditionalProperties = make(map[string]interface{}) + } + ae.AdditionalProperties[k] = additionalProperties + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ae.Type = &typeVar + } + } + } + + return nil +} + +// AlertList list of security alerts +type AlertList struct { + autorest.Response `json:"-"` + Value *[]Alert `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertList. +func (al AlertList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if al.Value != nil { + objectMap["value"] = al.Value + } + return json.Marshal(objectMap) +} + +// AlertListIterator provides access to a complete listing of Alert values. +type AlertListIterator struct { + i int + page AlertListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AlertListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AlertListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AlertListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AlertListIterator) Response() AlertList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AlertListIterator) Value() Alert { + if !iter.page.NotDone() { + return Alert{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AlertListIterator type. +func NewAlertListIterator(page AlertListPage) AlertListIterator { + return AlertListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (al AlertList) IsEmpty() bool { + return al.Value == nil || len(*al.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (al AlertList) hasNextLink() bool { + return al.NextLink != nil && len(*al.NextLink) != 0 +} + +// alertListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (al AlertList) alertListPreparer(ctx context.Context) (*http.Request, error) { + if !al.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(al.NextLink))) +} + +// AlertListPage contains a page of Alert values. +type AlertListPage struct { + fn func(context.Context, AlertList) (AlertList, error) + al AlertList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AlertListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.al) + if err != nil { + return err + } + page.al = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AlertListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AlertListPage) NotDone() bool { + return !page.al.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AlertListPage) Response() AlertList { + return page.al +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AlertListPage) Values() []Alert { + if page.al.IsEmpty() { + return nil + } + return *page.al.Value +} + +// Creates a new instance of the AlertListPage type. +func NewAlertListPage(getNextPage func(context.Context, AlertList) (AlertList, error)) AlertListPage { + return AlertListPage{fn: getNextPage} +} + +// AlertProperties describes security alert properties. +type AlertProperties struct { + // State - READ-ONLY; State of the alert (Active, Dismissed etc.) + State *string `json:"state,omitempty"` + // ReportedTimeUtc - READ-ONLY; The time the incident was reported to Microsoft.Security in UTC + ReportedTimeUtc *date.Time `json:"reportedTimeUtc,omitempty"` + // VendorName - READ-ONLY; Name of the vendor that discovered the incident + VendorName *string `json:"vendorName,omitempty"` + // AlertName - READ-ONLY; Name of the alert type + AlertName *string `json:"alertName,omitempty"` + // AlertDisplayName - READ-ONLY; Display name of the alert type + AlertDisplayName *string `json:"alertDisplayName,omitempty"` + // DetectedTimeUtc - READ-ONLY; The time the incident was detected by the vendor + DetectedTimeUtc *date.Time `json:"detectedTimeUtc,omitempty"` + // Description - READ-ONLY; Description of the incident and what it means + Description *string `json:"description,omitempty"` + // RemediationSteps - READ-ONLY; Recommended steps to reradiate the incident + RemediationSteps *string `json:"remediationSteps,omitempty"` + // ActionTaken - READ-ONLY; The action that was taken as a response to the alert (Active, Blocked etc.) + ActionTaken *string `json:"actionTaken,omitempty"` + // ReportedSeverity - READ-ONLY; Estimated severity of this alert. Possible values include: 'ReportedSeverityInformational', 'ReportedSeverityLow', 'ReportedSeverityMedium', 'ReportedSeverityHigh' + ReportedSeverity ReportedSeverity `json:"reportedSeverity,omitempty"` + // CompromisedEntity - READ-ONLY; The entity that the incident happened on + CompromisedEntity *string `json:"compromisedEntity,omitempty"` + // AssociatedResource - READ-ONLY; Azure resource ID of the associated resource + AssociatedResource *string `json:"associatedResource,omitempty"` + ExtendedProperties map[string]interface{} `json:"extendedProperties"` + // SystemSource - READ-ONLY; The type of the alerted resource (Azure, Non-Azure) + SystemSource *string `json:"systemSource,omitempty"` + // CanBeInvestigated - READ-ONLY; Whether this alert can be investigated with Azure Security Center + CanBeInvestigated *bool `json:"canBeInvestigated,omitempty"` + // IsIncident - READ-ONLY; Whether this alert is for incident type or not (otherwise - single alert) + IsIncident *bool `json:"isIncident,omitempty"` + // Entities - objects that are related to this alerts + Entities *[]AlertEntity `json:"entities,omitempty"` + // ConfidenceScore - READ-ONLY; level of confidence we have on the alert + ConfidenceScore *float64 `json:"confidenceScore,omitempty"` + // ConfidenceReasons - reasons the alert got the confidenceScore value + ConfidenceReasons *[]AlertConfidenceReason `json:"confidenceReasons,omitempty"` + // SubscriptionID - READ-ONLY; Azure subscription ID of the resource that had the security alert or the subscription ID of the workspace that this resource reports to + SubscriptionID *string `json:"subscriptionId,omitempty"` + // InstanceID - READ-ONLY; Instance ID of the alert. + InstanceID *string `json:"instanceId,omitempty"` + // WorkspaceArmID - READ-ONLY; Azure resource ID of the workspace that the alert was reported to. + WorkspaceArmID *string `json:"workspaceArmId,omitempty"` + // CorrelationKey - READ-ONLY; Alerts with the same CorrelationKey will be grouped together in Ibiza. + CorrelationKey *string `json:"correlationKey,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertProperties. +func (ap AlertProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ap.ExtendedProperties != nil { + objectMap["extendedProperties"] = ap.ExtendedProperties + } + if ap.Entities != nil { + objectMap["entities"] = ap.Entities + } + if ap.ConfidenceReasons != nil { + objectMap["confidenceReasons"] = ap.ConfidenceReasons + } + return json.Marshal(objectMap) +} + +// AlertsSuppressionRule describes the suppression rule +type AlertsSuppressionRule struct { + autorest.Response `json:"-"` + *AlertsSuppressionRuleProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertsSuppressionRule. +func (asr AlertsSuppressionRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asr.AlertsSuppressionRuleProperties != nil { + objectMap["properties"] = asr.AlertsSuppressionRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AlertsSuppressionRule struct. +func (asr *AlertsSuppressionRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var alertsSuppressionRuleProperties AlertsSuppressionRuleProperties + err = json.Unmarshal(*v, &alertsSuppressionRuleProperties) + if err != nil { + return err + } + asr.AlertsSuppressionRuleProperties = &alertsSuppressionRuleProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + asr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + asr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + asr.Type = &typeVar + } + } + } + + return nil +} + +// AlertsSuppressionRuleProperties describes AlertsSuppressionRule properties +type AlertsSuppressionRuleProperties struct { + // AlertType - Type of the alert to automatically suppress. For all alert types, use '*' + AlertType *string `json:"alertType,omitempty"` + // LastModifiedUtc - READ-ONLY; The last time this rule was modified + LastModifiedUtc *date.Time `json:"lastModifiedUtc,omitempty"` + // ExpirationDateUtc - Expiration date of the rule, if value is not provided or provided as null this field will default to the maximum allowed expiration date. + ExpirationDateUtc *date.Time `json:"expirationDateUtc,omitempty"` + // Reason - The reason for dismissing the alert + Reason *string `json:"reason,omitempty"` + // State - Possible states of the rule. Possible values include: 'RuleStateEnabled', 'RuleStateDisabled', 'RuleStateExpired' + State RuleState `json:"state,omitempty"` + // Comment - Any comment regarding the rule + Comment *string `json:"comment,omitempty"` + // SuppressionAlertsScope - The suppression conditions + SuppressionAlertsScope *SuppressionAlertsScope `json:"suppressionAlertsScope,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertsSuppressionRuleProperties. +func (asrp AlertsSuppressionRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asrp.AlertType != nil { + objectMap["alertType"] = asrp.AlertType + } + if asrp.ExpirationDateUtc != nil { + objectMap["expirationDateUtc"] = asrp.ExpirationDateUtc + } + if asrp.Reason != nil { + objectMap["reason"] = asrp.Reason + } + if asrp.State != "" { + objectMap["state"] = asrp.State + } + if asrp.Comment != nil { + objectMap["comment"] = asrp.Comment + } + if asrp.SuppressionAlertsScope != nil { + objectMap["suppressionAlertsScope"] = asrp.SuppressionAlertsScope + } + return json.Marshal(objectMap) +} + +// AlertsSuppressionRulesList suppression rules list for subscription. +type AlertsSuppressionRulesList struct { + autorest.Response `json:"-"` + Value *[]AlertsSuppressionRule `json:"value,omitempty"` + // NextLink - READ-ONLY; URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertsSuppressionRulesList. +func (asrl AlertsSuppressionRulesList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asrl.Value != nil { + objectMap["value"] = asrl.Value + } + return json.Marshal(objectMap) +} + +// AlertsSuppressionRulesListIterator provides access to a complete listing of AlertsSuppressionRule values. +type AlertsSuppressionRulesListIterator struct { + i int + page AlertsSuppressionRulesListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AlertsSuppressionRulesListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsSuppressionRulesListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AlertsSuppressionRulesListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AlertsSuppressionRulesListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AlertsSuppressionRulesListIterator) Response() AlertsSuppressionRulesList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AlertsSuppressionRulesListIterator) Value() AlertsSuppressionRule { + if !iter.page.NotDone() { + return AlertsSuppressionRule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AlertsSuppressionRulesListIterator type. +func NewAlertsSuppressionRulesListIterator(page AlertsSuppressionRulesListPage) AlertsSuppressionRulesListIterator { + return AlertsSuppressionRulesListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (asrl AlertsSuppressionRulesList) IsEmpty() bool { + return asrl.Value == nil || len(*asrl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (asrl AlertsSuppressionRulesList) hasNextLink() bool { + return asrl.NextLink != nil && len(*asrl.NextLink) != 0 +} + +// alertsSuppressionRulesListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (asrl AlertsSuppressionRulesList) alertsSuppressionRulesListPreparer(ctx context.Context) (*http.Request, error) { + if !asrl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(asrl.NextLink))) +} + +// AlertsSuppressionRulesListPage contains a page of AlertsSuppressionRule values. +type AlertsSuppressionRulesListPage struct { + fn func(context.Context, AlertsSuppressionRulesList) (AlertsSuppressionRulesList, error) + asrl AlertsSuppressionRulesList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AlertsSuppressionRulesListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsSuppressionRulesListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.asrl) + if err != nil { + return err + } + page.asrl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AlertsSuppressionRulesListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AlertsSuppressionRulesListPage) NotDone() bool { + return !page.asrl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AlertsSuppressionRulesListPage) Response() AlertsSuppressionRulesList { + return page.asrl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AlertsSuppressionRulesListPage) Values() []AlertsSuppressionRule { + if page.asrl.IsEmpty() { + return nil + } + return *page.asrl.Value +} + +// Creates a new instance of the AlertsSuppressionRulesListPage type. +func NewAlertsSuppressionRulesListPage(getNextPage func(context.Context, AlertsSuppressionRulesList) (AlertsSuppressionRulesList, error)) AlertsSuppressionRulesListPage { + return AlertsSuppressionRulesListPage{fn: getNextPage} +} + +// AllowedConnectionsList list of all possible traffic between Azure resources +type AllowedConnectionsList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY + Value *[]AllowedConnectionsResource `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// AllowedConnectionsListIterator provides access to a complete listing of AllowedConnectionsResource values. +type AllowedConnectionsListIterator struct { + i int + page AllowedConnectionsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AllowedConnectionsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AllowedConnectionsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AllowedConnectionsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AllowedConnectionsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AllowedConnectionsListIterator) Response() AllowedConnectionsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AllowedConnectionsListIterator) Value() AllowedConnectionsResource { + if !iter.page.NotDone() { + return AllowedConnectionsResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AllowedConnectionsListIterator type. +func NewAllowedConnectionsListIterator(page AllowedConnectionsListPage) AllowedConnectionsListIterator { + return AllowedConnectionsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ACL AllowedConnectionsList) IsEmpty() bool { + return ACL.Value == nil || len(*ACL.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ACL AllowedConnectionsList) hasNextLink() bool { + return ACL.NextLink != nil && len(*ACL.NextLink) != 0 +} + +// allowedConnectionsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ACL AllowedConnectionsList) allowedConnectionsListPreparer(ctx context.Context) (*http.Request, error) { + if !ACL.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ACL.NextLink))) +} + +// AllowedConnectionsListPage contains a page of AllowedConnectionsResource values. +type AllowedConnectionsListPage struct { + fn func(context.Context, AllowedConnectionsList) (AllowedConnectionsList, error) + ACL AllowedConnectionsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AllowedConnectionsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AllowedConnectionsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ACL) + if err != nil { + return err + } + page.ACL = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AllowedConnectionsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AllowedConnectionsListPage) NotDone() bool { + return !page.ACL.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AllowedConnectionsListPage) Response() AllowedConnectionsList { + return page.ACL +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AllowedConnectionsListPage) Values() []AllowedConnectionsResource { + if page.ACL.IsEmpty() { + return nil + } + return *page.ACL.Value +} + +// Creates a new instance of the AllowedConnectionsListPage type. +func NewAllowedConnectionsListPage(getNextPage func(context.Context, AllowedConnectionsList) (AllowedConnectionsList, error)) AllowedConnectionsListPage { + return AllowedConnectionsListPage{fn: getNextPage} +} + +// AllowedConnectionsResource the resource whose properties describes the allowed traffic between Azure +// resources +type AllowedConnectionsResource struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + // AllowedConnectionsResourceProperties - READ-ONLY + *AllowedConnectionsResourceProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AllowedConnectionsResource. +func (acr AllowedConnectionsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AllowedConnectionsResource struct. +func (acr *AllowedConnectionsResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + acr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + acr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + acr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + acr.Location = &location + } + case "properties": + if v != nil { + var allowedConnectionsResourceProperties AllowedConnectionsResourceProperties + err = json.Unmarshal(*v, &allowedConnectionsResourceProperties) + if err != nil { + return err + } + acr.AllowedConnectionsResourceProperties = &allowedConnectionsResourceProperties + } + } + } + + return nil +} + +// AllowedConnectionsResourceProperties describes the allowed traffic between Azure resources +type AllowedConnectionsResourceProperties struct { + // CalculatedDateTime - READ-ONLY; The UTC time on which the allowed connections resource was calculated + CalculatedDateTime *date.Time `json:"calculatedDateTime,omitempty"` + // ConnectableResources - READ-ONLY; List of connectable resources + ConnectableResources *[]ConnectableResource `json:"connectableResources,omitempty"` +} + +// BasicAllowlistCustomAlertRule a custom alert rule that checks if a value (depends on the custom alert type) is +// allowed. +type BasicAllowlistCustomAlertRule interface { + AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) + AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) + AsProcessNotAllowed() (*ProcessNotAllowed, bool) + AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) +} + +// AllowlistCustomAlertRule a custom alert rule that checks if a value (depends on the custom alert type) is +// allowed. +type AllowlistCustomAlertRule struct { + // AllowlistValues - The values to allow. The format of the values depends on the rule type. + AllowlistValues *[]string `json:"allowlistValues,omitempty"` + // ValueType - READ-ONLY; The value type of the items in the list. Possible values include: 'ValueTypeIPCidr', 'ValueTypeString' + ValueType ValueType `json:"valueType,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +func unmarshalBasicAllowlistCustomAlertRule(body []byte) (BasicAllowlistCustomAlertRule, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["ruleType"] { + case string(RuleTypeConnectionToIPNotAllowed): + var ctina ConnectionToIPNotAllowed + err := json.Unmarshal(body, &ctina) + return ctina, err + case string(RuleTypeLocalUserNotAllowed): + var luna LocalUserNotAllowed + err := json.Unmarshal(body, &luna) + return luna, err + case string(RuleTypeProcessNotAllowed): + var pna ProcessNotAllowed + err := json.Unmarshal(body, &pna) + return pna, err + default: + var acar AllowlistCustomAlertRule + err := json.Unmarshal(body, &acar) + return acar, err + } +} +func unmarshalBasicAllowlistCustomAlertRuleArray(body []byte) ([]BasicAllowlistCustomAlertRule, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + acarArray := make([]BasicAllowlistCustomAlertRule, len(rawMessages)) + + for index, rawMessage := range rawMessages { + acar, err := unmarshalBasicAllowlistCustomAlertRule(*rawMessage) + if err != nil { + return nil, err + } + acarArray[index] = acar + } + return acarArray, nil +} + +// MarshalJSON is the custom marshaler for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) MarshalJSON() ([]byte, error) { + acar.RuleType = RuleTypeAllowlistCustomAlertRule + objectMap := make(map[string]interface{}) + if acar.AllowlistValues != nil { + objectMap["allowlistValues"] = acar.AllowlistValues + } + if acar.IsEnabled != nil { + objectMap["isEnabled"] = acar.IsEnabled + } + if acar.RuleType != "" { + objectMap["ruleType"] = acar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return &acar, true +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return &acar, true +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return &acar, true +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for AllowlistCustomAlertRule. +func (acar AllowlistCustomAlertRule) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &acar, true +} + +// AmqpC2DMessagesNotInAllowedRange number of cloud to device messages (AMQP protocol) is not in allowed range. +type AmqpC2DMessagesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { + acmniar.RuleType = RuleTypeAmqpC2DMessagesNotInAllowedRange + objectMap := make(map[string]interface{}) + if acmniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = acmniar.TimeWindowSize + } + if acmniar.MinThreshold != nil { + objectMap["minThreshold"] = acmniar.MinThreshold + } + if acmniar.MaxThreshold != nil { + objectMap["maxThreshold"] = acmniar.MaxThreshold + } + if acmniar.IsEnabled != nil { + objectMap["isEnabled"] = acmniar.IsEnabled + } + if acmniar.RuleType != "" { + objectMap["ruleType"] = acmniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &acmniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &acmniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return &acmniar, true +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DMessagesNotInAllowedRange. +func (acmniar AmqpC2DMessagesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &acmniar, true +} + +// AmqpC2DRejectedMessagesNotInAllowedRange number of rejected cloud to device messages (AMQP protocol) is not +// in allowed range. +type AmqpC2DRejectedMessagesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { + acrmniar.RuleType = RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange + objectMap := make(map[string]interface{}) + if acrmniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = acrmniar.TimeWindowSize + } + if acrmniar.MinThreshold != nil { + objectMap["minThreshold"] = acrmniar.MinThreshold + } + if acrmniar.MaxThreshold != nil { + objectMap["maxThreshold"] = acrmniar.MaxThreshold + } + if acrmniar.IsEnabled != nil { + objectMap["isEnabled"] = acrmniar.IsEnabled + } + if acrmniar.RuleType != "" { + objectMap["ruleType"] = acrmniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &acrmniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &acrmniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return &acrmniar, true +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for AmqpC2DRejectedMessagesNotInAllowedRange. +func (acrmniar AmqpC2DRejectedMessagesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &acrmniar, true +} + +// AmqpD2CMessagesNotInAllowedRange number of device to cloud messages (AMQP protocol) is not in allowed range. +type AmqpD2CMessagesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { + admniar.RuleType = RuleTypeAmqpD2CMessagesNotInAllowedRange + objectMap := make(map[string]interface{}) + if admniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = admniar.TimeWindowSize + } + if admniar.MinThreshold != nil { + objectMap["minThreshold"] = admniar.MinThreshold + } + if admniar.MaxThreshold != nil { + objectMap["maxThreshold"] = admniar.MaxThreshold + } + if admniar.IsEnabled != nil { + objectMap["isEnabled"] = admniar.IsEnabled + } + if admniar.RuleType != "" { + objectMap["ruleType"] = admniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &admniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &admniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return &admniar, true +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for AmqpD2CMessagesNotInAllowedRange. +func (admniar AmqpD2CMessagesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &admniar, true +} + +// AscLocation the ASC location of the subscription is in the "name" field +type AscLocation struct { + autorest.Response `json:"-"` + Properties interface{} `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AscLocation. +func (al AscLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if al.Properties != nil { + objectMap["properties"] = al.Properties + } + return json.Marshal(objectMap) +} + +// AscLocationList list of locations where ASC saves your data +type AscLocationList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY + Value *[]AscLocation `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// AscLocationListIterator provides access to a complete listing of AscLocation values. +type AscLocationListIterator struct { + i int + page AscLocationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AscLocationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AscLocationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AscLocationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AscLocationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AscLocationListIterator) Response() AscLocationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AscLocationListIterator) Value() AscLocation { + if !iter.page.NotDone() { + return AscLocation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AscLocationListIterator type. +func NewAscLocationListIterator(page AscLocationListPage) AscLocationListIterator { + return AscLocationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (all AscLocationList) IsEmpty() bool { + return all.Value == nil || len(*all.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (all AscLocationList) hasNextLink() bool { + return all.NextLink != nil && len(*all.NextLink) != 0 +} + +// ascLocationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (all AscLocationList) ascLocationListPreparer(ctx context.Context) (*http.Request, error) { + if !all.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(all.NextLink))) +} + +// AscLocationListPage contains a page of AscLocation values. +type AscLocationListPage struct { + fn func(context.Context, AscLocationList) (AscLocationList, error) + all AscLocationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AscLocationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AscLocationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.all) + if err != nil { + return err + } + page.all = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AscLocationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AscLocationListPage) NotDone() bool { + return !page.all.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AscLocationListPage) Response() AscLocationList { + return page.all +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AscLocationListPage) Values() []AscLocation { + if page.all.IsEmpty() { + return nil + } + return *page.all.Value +} + +// Creates a new instance of the AscLocationListPage type. +func NewAscLocationListPage(getNextPage func(context.Context, AscLocationList) (AscLocationList, error)) AscLocationListPage { + return AscLocationListPage{fn: getNextPage} +} + +// Assessment security assessment on a resource +type Assessment struct { + autorest.Response `json:"-"` + *AssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Assessment. +func (a Assessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AssessmentProperties != nil { + objectMap["properties"] = a.AssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Assessment struct. +func (a *Assessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var assessmentProperties AssessmentProperties + err = json.Unmarshal(*v, &assessmentProperties) + if err != nil { + return err + } + a.AssessmentProperties = &assessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// AssessmentLinks links relevant to the assessment +type AssessmentLinks struct { + // AzurePortalURI - READ-ONLY; Link to assessment in Azure Portal + AzurePortalURI *string `json:"azurePortalUri,omitempty"` +} + +// AssessmentList page of a security assessments list +type AssessmentList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Collection of security assessments in this page + Value *[]Assessment `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// AssessmentListIterator provides access to a complete listing of Assessment values. +type AssessmentListIterator struct { + i int + page AssessmentListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AssessmentListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AssessmentListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AssessmentListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AssessmentListIterator) Response() AssessmentList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AssessmentListIterator) Value() Assessment { + if !iter.page.NotDone() { + return Assessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AssessmentListIterator type. +func NewAssessmentListIterator(page AssessmentListPage) AssessmentListIterator { + return AssessmentListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (al AssessmentList) IsEmpty() bool { + return al.Value == nil || len(*al.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (al AssessmentList) hasNextLink() bool { + return al.NextLink != nil && len(*al.NextLink) != 0 +} + +// assessmentListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (al AssessmentList) assessmentListPreparer(ctx context.Context) (*http.Request, error) { + if !al.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(al.NextLink))) +} + +// AssessmentListPage contains a page of Assessment values. +type AssessmentListPage struct { + fn func(context.Context, AssessmentList) (AssessmentList, error) + al AssessmentList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AssessmentListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.al) + if err != nil { + return err + } + page.al = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AssessmentListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AssessmentListPage) NotDone() bool { + return !page.al.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AssessmentListPage) Response() AssessmentList { + return page.al +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AssessmentListPage) Values() []Assessment { + if page.al.IsEmpty() { + return nil + } + return *page.al.Value +} + +// Creates a new instance of the AssessmentListPage type. +func NewAssessmentListPage(getNextPage func(context.Context, AssessmentList) (AssessmentList, error)) AssessmentListPage { + return AssessmentListPage{fn: getNextPage} +} + +// AssessmentMetadata security assessment metadata +type AssessmentMetadata struct { + autorest.Response `json:"-"` + *AssessmentMetadataProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AssessmentMetadata. +func (am AssessmentMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if am.AssessmentMetadataProperties != nil { + objectMap["properties"] = am.AssessmentMetadataProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AssessmentMetadata struct. +func (am *AssessmentMetadata) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var assessmentMetadataProperties AssessmentMetadataProperties + err = json.Unmarshal(*v, &assessmentMetadataProperties) + if err != nil { + return err + } + am.AssessmentMetadataProperties = &assessmentMetadataProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + am.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + am.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + am.Type = &typeVar + } + } + } + + return nil +} + +// AssessmentMetadataList list of security assessment metadata +type AssessmentMetadataList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY + Value *[]AssessmentMetadata `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// AssessmentMetadataListIterator provides access to a complete listing of AssessmentMetadata values. +type AssessmentMetadataListIterator struct { + i int + page AssessmentMetadataListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AssessmentMetadataListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentMetadataListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AssessmentMetadataListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AssessmentMetadataListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AssessmentMetadataListIterator) Response() AssessmentMetadataList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AssessmentMetadataListIterator) Value() AssessmentMetadata { + if !iter.page.NotDone() { + return AssessmentMetadata{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AssessmentMetadataListIterator type. +func NewAssessmentMetadataListIterator(page AssessmentMetadataListPage) AssessmentMetadataListIterator { + return AssessmentMetadataListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aml AssessmentMetadataList) IsEmpty() bool { + return aml.Value == nil || len(*aml.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (aml AssessmentMetadataList) hasNextLink() bool { + return aml.NextLink != nil && len(*aml.NextLink) != 0 +} + +// assessmentMetadataListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aml AssessmentMetadataList) assessmentMetadataListPreparer(ctx context.Context) (*http.Request, error) { + if !aml.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aml.NextLink))) +} + +// AssessmentMetadataListPage contains a page of AssessmentMetadata values. +type AssessmentMetadataListPage struct { + fn func(context.Context, AssessmentMetadataList) (AssessmentMetadataList, error) + aml AssessmentMetadataList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AssessmentMetadataListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AssessmentMetadataListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.aml) + if err != nil { + return err + } + page.aml = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AssessmentMetadataListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AssessmentMetadataListPage) NotDone() bool { + return !page.aml.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AssessmentMetadataListPage) Response() AssessmentMetadataList { + return page.aml +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AssessmentMetadataListPage) Values() []AssessmentMetadata { + if page.aml.IsEmpty() { + return nil + } + return *page.aml.Value +} + +// Creates a new instance of the AssessmentMetadataListPage type. +func NewAssessmentMetadataListPage(getNextPage func(context.Context, AssessmentMetadataList) (AssessmentMetadataList, error)) AssessmentMetadataListPage { + return AssessmentMetadataListPage{fn: getNextPage} +} + +// AssessmentMetadataPartnerData describes the partner that created the assessment +type AssessmentMetadataPartnerData struct { + // PartnerName - Name of the company of the partner + PartnerName *string `json:"partnerName,omitempty"` + // ProductName - Name of the product of the partner that created the assessment + ProductName *string `json:"productName,omitempty"` + // Secret - Secret to authenticate the partner and verify it created the assessment - write only + Secret *string `json:"secret,omitempty"` +} + +// AssessmentMetadataProperties describes properties of an assessment metadata. +type AssessmentMetadataProperties struct { + // DisplayName - User friendly display name of the assessment + DisplayName *string `json:"displayName,omitempty"` + // PolicyDefinitionID - READ-ONLY; Azure resource ID of the policy definition that turns this assessment calculation on + PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` + // Description - Human readable description of the assessment + Description *string `json:"description,omitempty"` + // RemediationDescription - Human readable description of what you should do to mitigate this security issue + RemediationDescription *string `json:"remediationDescription,omitempty"` + Category *[]Category `json:"category,omitempty"` + // Severity - The severity level of the assessment. Possible values include: 'SeverityLow', 'SeverityMedium', 'SeverityHigh' + Severity Severity `json:"severity,omitempty"` + // UserImpact - The user impact of the assessment. Possible values include: 'UserImpactLow', 'UserImpactModerate', 'UserImpactHigh' + UserImpact UserImpact `json:"userImpact,omitempty"` + // ImplementationEffort - The implementation effort required to remediate this assessment. Possible values include: 'ImplementationEffortLow', 'ImplementationEffortModerate', 'ImplementationEffortHigh' + ImplementationEffort ImplementationEffort `json:"implementationEffort,omitempty"` + Threats *[]Threats `json:"threats,omitempty"` + // Preview - True if this assessment is in preview release status + Preview *bool `json:"preview,omitempty"` + // AssessmentType - BuiltIn if the assessment based on built-in Azure Policy definition, Custom if the assessment based on custom Azure Policy definition. Possible values include: 'BuiltIn', 'CustomPolicy', 'CustomerManaged', 'VerifiedPartner' + AssessmentType AssessmentType `json:"assessmentType,omitempty"` + PartnerData *AssessmentMetadataPartnerData `json:"partnerData,omitempty"` +} + +// MarshalJSON is the custom marshaler for AssessmentMetadataProperties. +func (amp AssessmentMetadataProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if amp.DisplayName != nil { + objectMap["displayName"] = amp.DisplayName + } + if amp.Description != nil { + objectMap["description"] = amp.Description + } + if amp.RemediationDescription != nil { + objectMap["remediationDescription"] = amp.RemediationDescription + } + if amp.Category != nil { + objectMap["category"] = amp.Category + } + if amp.Severity != "" { + objectMap["severity"] = amp.Severity + } + if amp.UserImpact != "" { + objectMap["userImpact"] = amp.UserImpact + } + if amp.ImplementationEffort != "" { + objectMap["implementationEffort"] = amp.ImplementationEffort + } + if amp.Threats != nil { + objectMap["threats"] = amp.Threats + } + if amp.Preview != nil { + objectMap["preview"] = amp.Preview + } + if amp.AssessmentType != "" { + objectMap["assessmentType"] = amp.AssessmentType + } + if amp.PartnerData != nil { + objectMap["partnerData"] = amp.PartnerData + } + return json.Marshal(objectMap) +} + +// AssessmentPartnerData data regarding 3rd party partner integration +type AssessmentPartnerData struct { + // PartnerName - Name of the company of the partner + PartnerName *string `json:"partnerName,omitempty"` + // Secret - secret to authenticate the partner - write only + Secret *string `json:"secret,omitempty"` +} + +// AssessmentProperties describes properties of an assessment. +type AssessmentProperties struct { + ResourceDetails BasicResourceDetails `json:"resourceDetails,omitempty"` + // DisplayName - READ-ONLY; User friendly display name of the assessment + DisplayName *string `json:"displayName,omitempty"` + Status *AssessmentStatus `json:"status,omitempty"` + // AdditionalData - Additional data regarding the assessment + AdditionalData map[string]*string `json:"additionalData"` + Links *AssessmentLinks `json:"links,omitempty"` + Metadata *AssessmentMetadataProperties `json:"metadata,omitempty"` + PartnersData *AssessmentPartnerData `json:"partnersData,omitempty"` +} + +// MarshalJSON is the custom marshaler for AssessmentProperties. +func (ap AssessmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["resourceDetails"] = ap.ResourceDetails + if ap.Status != nil { + objectMap["status"] = ap.Status + } + if ap.AdditionalData != nil { + objectMap["additionalData"] = ap.AdditionalData + } + if ap.Links != nil { + objectMap["links"] = ap.Links + } + if ap.Metadata != nil { + objectMap["metadata"] = ap.Metadata + } + if ap.PartnersData != nil { + objectMap["partnersData"] = ap.PartnersData + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AssessmentProperties struct. +func (ap *AssessmentProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "resourceDetails": + if v != nil { + resourceDetails, err := unmarshalBasicResourceDetails(*v) + if err != nil { + return err + } + ap.ResourceDetails = resourceDetails + } + case "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + ap.DisplayName = &displayName + } + case "status": + if v != nil { + var status AssessmentStatus + err = json.Unmarshal(*v, &status) + if err != nil { + return err + } + ap.Status = &status + } + case "additionalData": + if v != nil { + var additionalData map[string]*string + err = json.Unmarshal(*v, &additionalData) + if err != nil { + return err + } + ap.AdditionalData = additionalData + } + case "links": + if v != nil { + var links AssessmentLinks + err = json.Unmarshal(*v, &links) + if err != nil { + return err + } + ap.Links = &links + } + case "metadata": + if v != nil { + var metadata AssessmentMetadataProperties + err = json.Unmarshal(*v, &metadata) + if err != nil { + return err + } + ap.Metadata = &metadata + } + case "partnersData": + if v != nil { + var partnersData AssessmentPartnerData + err = json.Unmarshal(*v, &partnersData) + if err != nil { + return err + } + ap.PartnersData = &partnersData + } + } + } + + return nil +} + +// AssessmentStatus the result of the assessment +type AssessmentStatus struct { + // Code - Programmatic code for the status of the assessment. Possible values include: 'Healthy', 'Unhealthy', 'NotApplicable' + Code AssessmentStatusCode `json:"code,omitempty"` + // Cause - Programmatic code for the cause of the assessment status + Cause *string `json:"cause,omitempty"` + // Description - Human readable description of the assessment status + Description *string `json:"description,omitempty"` +} + +// AtaExternalSecuritySolution represents an ATA security solution which sends logs to an OMS workspace +type AtaExternalSecuritySolution struct { + Properties *AtaSolutionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + // Kind - Possible values include: 'KindExternalSecuritySolution', 'KindCEF', 'KindATA', 'KindAAD' + Kind KindEnum1 `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for AtaExternalSecuritySolution. +func (aess AtaExternalSecuritySolution) MarshalJSON() ([]byte, error) { + aess.Kind = KindATA + objectMap := make(map[string]interface{}) + if aess.Properties != nil { + objectMap["properties"] = aess.Properties + } + if aess.Kind != "" { + objectMap["kind"] = aess.Kind + } + return json.Marshal(objectMap) +} + +// AsCefExternalSecuritySolution is the BasicExternalSecuritySolution implementation for AtaExternalSecuritySolution. +func (aess AtaExternalSecuritySolution) AsCefExternalSecuritySolution() (*CefExternalSecuritySolution, bool) { + return nil, false +} + +// AsAtaExternalSecuritySolution is the BasicExternalSecuritySolution implementation for AtaExternalSecuritySolution. +func (aess AtaExternalSecuritySolution) AsAtaExternalSecuritySolution() (*AtaExternalSecuritySolution, bool) { + return &aess, true +} + +// AsAadExternalSecuritySolution is the BasicExternalSecuritySolution implementation for AtaExternalSecuritySolution. +func (aess AtaExternalSecuritySolution) AsAadExternalSecuritySolution() (*AadExternalSecuritySolution, bool) { + return nil, false +} + +// AsExternalSecuritySolution is the BasicExternalSecuritySolution implementation for AtaExternalSecuritySolution. +func (aess AtaExternalSecuritySolution) AsExternalSecuritySolution() (*ExternalSecuritySolution, bool) { + return nil, false +} + +// AsBasicExternalSecuritySolution is the BasicExternalSecuritySolution implementation for AtaExternalSecuritySolution. +func (aess AtaExternalSecuritySolution) AsBasicExternalSecuritySolution() (BasicExternalSecuritySolution, bool) { + return &aess, true +} + +// AtaSolutionProperties ... +type AtaSolutionProperties struct { + LastEventReceived *string `json:"lastEventReceived,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + DeviceVendor *string `json:"deviceVendor,omitempty"` + DeviceType *string `json:"deviceType,omitempty"` + Workspace *ConnectedWorkspace `json:"workspace,omitempty"` +} + +// MarshalJSON is the custom marshaler for AtaSolutionProperties. +func (asp AtaSolutionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asp.LastEventReceived != nil { + objectMap["lastEventReceived"] = asp.LastEventReceived + } + if asp.DeviceVendor != nil { + objectMap["deviceVendor"] = asp.DeviceVendor + } + if asp.DeviceType != nil { + objectMap["deviceType"] = asp.DeviceType + } + if asp.Workspace != nil { + objectMap["workspace"] = asp.Workspace + } + for k, v := range asp.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AtaSolutionProperties struct. +func (asp *AtaSolutionProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "lastEventReceived": + if v != nil { + var lastEventReceived string + err = json.Unmarshal(*v, &lastEventReceived) + if err != nil { + return err + } + asp.LastEventReceived = &lastEventReceived + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if asp.AdditionalProperties == nil { + asp.AdditionalProperties = make(map[string]interface{}) + } + asp.AdditionalProperties[k] = additionalProperties + } + case "deviceVendor": + if v != nil { + var deviceVendor string + err = json.Unmarshal(*v, &deviceVendor) + if err != nil { + return err + } + asp.DeviceVendor = &deviceVendor + } + case "deviceType": + if v != nil { + var deviceType string + err = json.Unmarshal(*v, &deviceType) + if err != nil { + return err + } + asp.DeviceType = &deviceType + } + case "workspace": + if v != nil { + var workspace ConnectedWorkspace + err = json.Unmarshal(*v, &workspace) + if err != nil { + return err + } + asp.Workspace = &workspace + } + } + } + + return nil +} + +// BasicAuthenticationDetailsProperties settings for cloud authentication management +type BasicAuthenticationDetailsProperties interface { + AsAwsCredsAuthenticationDetailsProperties() (*AwsCredsAuthenticationDetailsProperties, bool) + AsAwAssumeRoleAuthenticationDetailsProperties() (*AwAssumeRoleAuthenticationDetailsProperties, bool) + AsGcpCredentialsDetailsProperties() (*GcpCredentialsDetailsProperties, bool) + AsAuthenticationDetailsProperties() (*AuthenticationDetailsProperties, bool) +} + +// AuthenticationDetailsProperties settings for cloud authentication management +type AuthenticationDetailsProperties struct { + // AuthenticationProvisioningState - READ-ONLY; State of the multi-cloud connector. Possible values include: 'Valid', 'Invalid', 'Expired', 'IncorrectPolicy' + AuthenticationProvisioningState AuthenticationProvisioningState `json:"authenticationProvisioningState,omitempty"` + // GrantedPermissions - READ-ONLY; The permissions detected in the cloud account. + GrantedPermissions *[]PermissionProperty `json:"grantedPermissions,omitempty"` + // AuthenticationType - Possible values include: 'AuthenticationTypeAuthenticationDetailsProperties', 'AuthenticationTypeAwsCreds', 'AuthenticationTypeAwsAssumeRole', 'AuthenticationTypeGcpCredentials' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` +} + +func unmarshalBasicAuthenticationDetailsProperties(body []byte) (BasicAuthenticationDetailsProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["authenticationType"] { + case string(AuthenticationTypeAwsCreds): + var acadp AwsCredsAuthenticationDetailsProperties + err := json.Unmarshal(body, &acadp) + return acadp, err + case string(AuthenticationTypeAwsAssumeRole): + var aaradp AwAssumeRoleAuthenticationDetailsProperties + err := json.Unmarshal(body, &aaradp) + return aaradp, err + case string(AuthenticationTypeGcpCredentials): + var gcdp GcpCredentialsDetailsProperties + err := json.Unmarshal(body, &gcdp) + return gcdp, err + default: + var adp AuthenticationDetailsProperties + err := json.Unmarshal(body, &adp) + return adp, err + } +} +func unmarshalBasicAuthenticationDetailsPropertiesArray(body []byte) ([]BasicAuthenticationDetailsProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + adpArray := make([]BasicAuthenticationDetailsProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + adp, err := unmarshalBasicAuthenticationDetailsProperties(*rawMessage) + if err != nil { + return nil, err + } + adpArray[index] = adp + } + return adpArray, nil +} + +// MarshalJSON is the custom marshaler for AuthenticationDetailsProperties. +func (adp AuthenticationDetailsProperties) MarshalJSON() ([]byte, error) { + adp.AuthenticationType = AuthenticationTypeAuthenticationDetailsProperties + objectMap := make(map[string]interface{}) + if adp.AuthenticationType != "" { + objectMap["authenticationType"] = adp.AuthenticationType + } + return json.Marshal(objectMap) +} + +// AsAwsCredsAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AuthenticationDetailsProperties. +func (adp AuthenticationDetailsProperties) AsAwsCredsAuthenticationDetailsProperties() (*AwsCredsAuthenticationDetailsProperties, bool) { + return nil, false +} + +// AsAwAssumeRoleAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AuthenticationDetailsProperties. +func (adp AuthenticationDetailsProperties) AsAwAssumeRoleAuthenticationDetailsProperties() (*AwAssumeRoleAuthenticationDetailsProperties, bool) { + return nil, false +} + +// AsGcpCredentialsDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AuthenticationDetailsProperties. +func (adp AuthenticationDetailsProperties) AsGcpCredentialsDetailsProperties() (*GcpCredentialsDetailsProperties, bool) { + return nil, false +} + +// AsAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AuthenticationDetailsProperties. +func (adp AuthenticationDetailsProperties) AsAuthenticationDetailsProperties() (*AuthenticationDetailsProperties, bool) { + return &adp, true +} + +// AsBasicAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AuthenticationDetailsProperties. +func (adp AuthenticationDetailsProperties) AsBasicAuthenticationDetailsProperties() (BasicAuthenticationDetailsProperties, bool) { + return &adp, true +} + +// Automation the security automation resource. +type Automation struct { + autorest.Response `json:"-"` + // AutomationProperties - Security automation data + *AutomationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + // Kind - Kind of the resource + Kind *string `json:"kind,omitempty"` + // Etag - Entity tag is used for comparing two or more entities from the same requested resource. + Etag *string `json:"etag,omitempty"` + // Tags - A list of key value pairs that describe the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Automation. +func (a Automation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AutomationProperties != nil { + objectMap["properties"] = a.AutomationProperties + } + if a.Kind != nil { + objectMap["kind"] = a.Kind + } + if a.Etag != nil { + objectMap["etag"] = a.Etag + } + if a.Tags != nil { + objectMap["tags"] = a.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Automation struct. +func (a *Automation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var automationProperties AutomationProperties + err = json.Unmarshal(*v, &automationProperties) + if err != nil { + return err + } + a.AutomationProperties = &automationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + a.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + a.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + a.Etag = &etag + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + a.Tags = tags + } + } + } + + return nil +} + +// BasicAutomationAction the action that should be triggered. +type BasicAutomationAction interface { + AsAutomationActionLogicApp() (*AutomationActionLogicApp, bool) + AsAutomationActionEventHub() (*AutomationActionEventHub, bool) + AsAutomationActionWorkspace() (*AutomationActionWorkspace, bool) + AsAutomationAction() (*AutomationAction, bool) +} + +// AutomationAction the action that should be triggered. +type AutomationAction struct { + // ActionType - Possible values include: 'ActionTypeAutomationAction', 'ActionTypeLogicApp', 'ActionTypeEventHub', 'ActionTypeWorkspace' + ActionType ActionType `json:"actionType,omitempty"` +} + +func unmarshalBasicAutomationAction(body []byte) (BasicAutomationAction, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["actionType"] { + case string(ActionTypeLogicApp): + var aala AutomationActionLogicApp + err := json.Unmarshal(body, &aala) + return aala, err + case string(ActionTypeEventHub): + var aaeh AutomationActionEventHub + err := json.Unmarshal(body, &aaeh) + return aaeh, err + case string(ActionTypeWorkspace): + var aaw AutomationActionWorkspace + err := json.Unmarshal(body, &aaw) + return aaw, err + default: + var aa AutomationAction + err := json.Unmarshal(body, &aa) + return aa, err + } +} +func unmarshalBasicAutomationActionArray(body []byte) ([]BasicAutomationAction, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + aaArray := make([]BasicAutomationAction, len(rawMessages)) + + for index, rawMessage := range rawMessages { + aa, err := unmarshalBasicAutomationAction(*rawMessage) + if err != nil { + return nil, err + } + aaArray[index] = aa + } + return aaArray, nil +} + +// MarshalJSON is the custom marshaler for AutomationAction. +func (aa AutomationAction) MarshalJSON() ([]byte, error) { + aa.ActionType = ActionTypeAutomationAction + objectMap := make(map[string]interface{}) + if aa.ActionType != "" { + objectMap["actionType"] = aa.ActionType + } + return json.Marshal(objectMap) +} + +// AsAutomationActionLogicApp is the BasicAutomationAction implementation for AutomationAction. +func (aa AutomationAction) AsAutomationActionLogicApp() (*AutomationActionLogicApp, bool) { + return nil, false +} + +// AsAutomationActionEventHub is the BasicAutomationAction implementation for AutomationAction. +func (aa AutomationAction) AsAutomationActionEventHub() (*AutomationActionEventHub, bool) { + return nil, false +} + +// AsAutomationActionWorkspace is the BasicAutomationAction implementation for AutomationAction. +func (aa AutomationAction) AsAutomationActionWorkspace() (*AutomationActionWorkspace, bool) { + return nil, false +} + +// AsAutomationAction is the BasicAutomationAction implementation for AutomationAction. +func (aa AutomationAction) AsAutomationAction() (*AutomationAction, bool) { + return &aa, true +} + +// AsBasicAutomationAction is the BasicAutomationAction implementation for AutomationAction. +func (aa AutomationAction) AsBasicAutomationAction() (BasicAutomationAction, bool) { + return &aa, true +} + +// AutomationActionEventHub the target Event Hub to which event data will be exported. To learn more about +// Security Center continuous export capabilities, visit https://aka.ms/ASCExportLearnMore +type AutomationActionEventHub struct { + // EventHubResourceID - The target Event Hub Azure Resource ID. + EventHubResourceID *string `json:"eventHubResourceId,omitempty"` + // SasPolicyName - READ-ONLY; The target Event Hub SAS policy name. + SasPolicyName *string `json:"sasPolicyName,omitempty"` + // ConnectionString - The target Event Hub connection string (it will not be included in any response). + ConnectionString *string `json:"connectionString,omitempty"` + // ActionType - Possible values include: 'ActionTypeAutomationAction', 'ActionTypeLogicApp', 'ActionTypeEventHub', 'ActionTypeWorkspace' + ActionType ActionType `json:"actionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutomationActionEventHub. +func (aaeh AutomationActionEventHub) MarshalJSON() ([]byte, error) { + aaeh.ActionType = ActionTypeEventHub + objectMap := make(map[string]interface{}) + if aaeh.EventHubResourceID != nil { + objectMap["eventHubResourceId"] = aaeh.EventHubResourceID + } + if aaeh.ConnectionString != nil { + objectMap["connectionString"] = aaeh.ConnectionString + } + if aaeh.ActionType != "" { + objectMap["actionType"] = aaeh.ActionType + } + return json.Marshal(objectMap) +} + +// AsAutomationActionLogicApp is the BasicAutomationAction implementation for AutomationActionEventHub. +func (aaeh AutomationActionEventHub) AsAutomationActionLogicApp() (*AutomationActionLogicApp, bool) { + return nil, false +} + +// AsAutomationActionEventHub is the BasicAutomationAction implementation for AutomationActionEventHub. +func (aaeh AutomationActionEventHub) AsAutomationActionEventHub() (*AutomationActionEventHub, bool) { + return &aaeh, true +} + +// AsAutomationActionWorkspace is the BasicAutomationAction implementation for AutomationActionEventHub. +func (aaeh AutomationActionEventHub) AsAutomationActionWorkspace() (*AutomationActionWorkspace, bool) { + return nil, false +} + +// AsAutomationAction is the BasicAutomationAction implementation for AutomationActionEventHub. +func (aaeh AutomationActionEventHub) AsAutomationAction() (*AutomationAction, bool) { + return nil, false +} + +// AsBasicAutomationAction is the BasicAutomationAction implementation for AutomationActionEventHub. +func (aaeh AutomationActionEventHub) AsBasicAutomationAction() (BasicAutomationAction, bool) { + return &aaeh, true +} + +// AutomationActionLogicApp the logic app action that should be triggered. To learn more about Security +// Center's Workflow Automation capabilities, visit https://aka.ms/ASCWorkflowAutomationLearnMore +type AutomationActionLogicApp struct { + // LogicAppResourceID - The triggered Logic App Azure Resource ID. This can also reside on other subscriptions, given that you have permissions to trigger the Logic App + LogicAppResourceID *string `json:"logicAppResourceId,omitempty"` + // URI - The Logic App trigger URI endpoint (it will not be included in any response). + URI *string `json:"uri,omitempty"` + // ActionType - Possible values include: 'ActionTypeAutomationAction', 'ActionTypeLogicApp', 'ActionTypeEventHub', 'ActionTypeWorkspace' + ActionType ActionType `json:"actionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutomationActionLogicApp. +func (aala AutomationActionLogicApp) MarshalJSON() ([]byte, error) { + aala.ActionType = ActionTypeLogicApp + objectMap := make(map[string]interface{}) + if aala.LogicAppResourceID != nil { + objectMap["logicAppResourceId"] = aala.LogicAppResourceID + } + if aala.URI != nil { + objectMap["uri"] = aala.URI + } + if aala.ActionType != "" { + objectMap["actionType"] = aala.ActionType + } + return json.Marshal(objectMap) +} + +// AsAutomationActionLogicApp is the BasicAutomationAction implementation for AutomationActionLogicApp. +func (aala AutomationActionLogicApp) AsAutomationActionLogicApp() (*AutomationActionLogicApp, bool) { + return &aala, true +} + +// AsAutomationActionEventHub is the BasicAutomationAction implementation for AutomationActionLogicApp. +func (aala AutomationActionLogicApp) AsAutomationActionEventHub() (*AutomationActionEventHub, bool) { + return nil, false +} + +// AsAutomationActionWorkspace is the BasicAutomationAction implementation for AutomationActionLogicApp. +func (aala AutomationActionLogicApp) AsAutomationActionWorkspace() (*AutomationActionWorkspace, bool) { + return nil, false +} + +// AsAutomationAction is the BasicAutomationAction implementation for AutomationActionLogicApp. +func (aala AutomationActionLogicApp) AsAutomationAction() (*AutomationAction, bool) { + return nil, false +} + +// AsBasicAutomationAction is the BasicAutomationAction implementation for AutomationActionLogicApp. +func (aala AutomationActionLogicApp) AsBasicAutomationAction() (BasicAutomationAction, bool) { + return &aala, true +} + +// AutomationActionWorkspace the Log Analytics Workspace to which event data will be exported. Security alerts +// data will reside in the 'SecurityAlert' table and the assessments data will reside in the +// 'SecurityRecommendation' table (under the 'Security'/'SecurityCenterFree' solutions). Note that in order to +// view the data in the workspace, the Security Center Log Analytics free/standard solution needs to be enabled +// on that workspace. To learn more about Security Center continuous export capabilities, visit +// https://aka.ms/ASCExportLearnMore +type AutomationActionWorkspace struct { + // WorkspaceResourceID - The fully qualified Log Analytics Workspace Azure Resource ID. + WorkspaceResourceID *string `json:"workspaceResourceId,omitempty"` + // ActionType - Possible values include: 'ActionTypeAutomationAction', 'ActionTypeLogicApp', 'ActionTypeEventHub', 'ActionTypeWorkspace' + ActionType ActionType `json:"actionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutomationActionWorkspace. +func (aaw AutomationActionWorkspace) MarshalJSON() ([]byte, error) { + aaw.ActionType = ActionTypeWorkspace + objectMap := make(map[string]interface{}) + if aaw.WorkspaceResourceID != nil { + objectMap["workspaceResourceId"] = aaw.WorkspaceResourceID + } + if aaw.ActionType != "" { + objectMap["actionType"] = aaw.ActionType + } + return json.Marshal(objectMap) +} + +// AsAutomationActionLogicApp is the BasicAutomationAction implementation for AutomationActionWorkspace. +func (aaw AutomationActionWorkspace) AsAutomationActionLogicApp() (*AutomationActionLogicApp, bool) { + return nil, false +} + +// AsAutomationActionEventHub is the BasicAutomationAction implementation for AutomationActionWorkspace. +func (aaw AutomationActionWorkspace) AsAutomationActionEventHub() (*AutomationActionEventHub, bool) { + return nil, false +} + +// AsAutomationActionWorkspace is the BasicAutomationAction implementation for AutomationActionWorkspace. +func (aaw AutomationActionWorkspace) AsAutomationActionWorkspace() (*AutomationActionWorkspace, bool) { + return &aaw, true +} + +// AsAutomationAction is the BasicAutomationAction implementation for AutomationActionWorkspace. +func (aaw AutomationActionWorkspace) AsAutomationAction() (*AutomationAction, bool) { + return nil, false +} + +// AsBasicAutomationAction is the BasicAutomationAction implementation for AutomationActionWorkspace. +func (aaw AutomationActionWorkspace) AsBasicAutomationAction() (BasicAutomationAction, bool) { + return &aaw, true +} + +// AutomationList list of security automations response. +type AutomationList struct { + autorest.Response `json:"-"` + // Value - The list of security automations under the given scope. + Value *[]Automation `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutomationList. +func (al AutomationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if al.Value != nil { + objectMap["value"] = al.Value + } + return json.Marshal(objectMap) +} + +// AutomationListIterator provides access to a complete listing of Automation values. +type AutomationListIterator struct { + i int + page AutomationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AutomationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutomationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AutomationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AutomationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AutomationListIterator) Response() AutomationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AutomationListIterator) Value() Automation { + if !iter.page.NotDone() { + return Automation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AutomationListIterator type. +func NewAutomationListIterator(page AutomationListPage) AutomationListIterator { + return AutomationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (al AutomationList) IsEmpty() bool { + return al.Value == nil || len(*al.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (al AutomationList) hasNextLink() bool { + return al.NextLink != nil && len(*al.NextLink) != 0 +} + +// automationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (al AutomationList) automationListPreparer(ctx context.Context) (*http.Request, error) { + if !al.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(al.NextLink))) +} + +// AutomationListPage contains a page of Automation values. +type AutomationListPage struct { + fn func(context.Context, AutomationList) (AutomationList, error) + al AutomationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AutomationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutomationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.al) + if err != nil { + return err + } + page.al = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AutomationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AutomationListPage) NotDone() bool { + return !page.al.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AutomationListPage) Response() AutomationList { + return page.al +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AutomationListPage) Values() []Automation { + if page.al.IsEmpty() { + return nil + } + return *page.al.Value +} + +// Creates a new instance of the AutomationListPage type. +func NewAutomationListPage(getNextPage func(context.Context, AutomationList) (AutomationList, error)) AutomationListPage { + return AutomationListPage{fn: getNextPage} +} + +// AutomationProperties a set of properties that defines the behavior of the automation configuration. To learn +// more about the supported security events data models schemas - please visit +// https://aka.ms/ASCAutomationSchemas. +type AutomationProperties struct { + // Description - The security automation description. + Description *string `json:"description,omitempty"` + // IsEnabled - Indicates whether the security automation is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` + // Scopes - A collection of scopes on which the security automations logic is applied. Supported scopes are the subscription itself or a resource group under that subscription. The automation will only apply on defined scopes. + Scopes *[]AutomationScope `json:"scopes,omitempty"` + // Sources - A collection of the source event types which evaluate the security automation set of rules. + Sources *[]AutomationSource `json:"sources,omitempty"` + // Actions - A collection of the actions which are triggered if all the configured rules evaluations, within at least one rule set, are true. + Actions *[]BasicAutomationAction `json:"actions,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for AutomationProperties struct. +func (ap *AutomationProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + ap.Description = &description + } + case "isEnabled": + if v != nil { + var isEnabled bool + err = json.Unmarshal(*v, &isEnabled) + if err != nil { + return err + } + ap.IsEnabled = &isEnabled + } + case "scopes": + if v != nil { + var scopes []AutomationScope + err = json.Unmarshal(*v, &scopes) + if err != nil { + return err + } + ap.Scopes = &scopes + } + case "sources": + if v != nil { + var sources []AutomationSource + err = json.Unmarshal(*v, &sources) + if err != nil { + return err + } + ap.Sources = &sources + } + case "actions": + if v != nil { + actions, err := unmarshalBasicAutomationActionArray(*v) + if err != nil { + return err + } + ap.Actions = &actions + } + } + } + + return nil +} + +// AutomationRuleSet a rule set which evaluates all its rules upon an event interception. Only when all the +// included rules in the rule set will be evaluated as 'true', will the event trigger the defined actions. +type AutomationRuleSet struct { + Rules *[]AutomationTriggeringRule `json:"rules,omitempty"` +} + +// AutomationScope a single automation scope. +type AutomationScope struct { + // Description - The resources scope description. + Description *string `json:"description,omitempty"` + // ScopePath - The resources scope path. Can be the subscription on which the automation is defined on or a resource group under that subscription (fully qualified Azure resource IDs). + ScopePath *string `json:"scopePath,omitempty"` +} + +// AutomationSource the source event types which evaluate the security automation set of rules. For example - +// security alerts and security assessments. To learn more about the supported security events data models +// schemas - please visit https://aka.ms/ASCAutomationSchemas. +type AutomationSource struct { + // EventSource - A valid event source type. Possible values include: 'Assessments', 'Alerts' + EventSource EventSource `json:"eventSource,omitempty"` + // RuleSets - A set of rules which evaluate upon event interception. A logical disjunction is applied between defined rule sets (logical 'or'). + RuleSets *[]AutomationRuleSet `json:"ruleSets,omitempty"` +} + +// AutomationTriggeringRule a rule which is evaluated upon event interception. The rule is configured by +// comparing a specific value from the event model to an expected value. This comparison is done by using one +// of the supported operators set. +type AutomationTriggeringRule struct { + // PropertyJPath - The JPath of the entity model property that should be checked. + PropertyJPath *string `json:"propertyJPath,omitempty"` + // PropertyType - The data type of the compared operands (string, integer, floating point number or a boolean [true/false]]. Possible values include: 'String', 'Integer', 'Number', 'Boolean' + PropertyType PropertyType `json:"propertyType,omitempty"` + // ExpectedValue - The expected value. + ExpectedValue *string `json:"expectedValue,omitempty"` + // Operator - A valid comparer operator to use. A case-insensitive comparison will be applied for String PropertyType. Possible values include: 'Equals', 'GreaterThan', 'GreaterThanOrEqualTo', 'LesserThan', 'LesserThanOrEqualTo', 'NotEquals', 'Contains', 'StartsWith', 'EndsWith' + Operator Operator `json:"operator,omitempty"` +} + +// AutomationValidationStatus the security automation model state property bag. +type AutomationValidationStatus struct { + autorest.Response `json:"-"` + // IsValid - Indicates whether the model is valid or not. + IsValid *bool `json:"isValid,omitempty"` + // Message - The validation message. + Message *string `json:"message,omitempty"` +} + +// AutoProvisioningSetting auto provisioning setting +type AutoProvisioningSetting struct { + autorest.Response `json:"-"` + // AutoProvisioningSettingProperties - Auto provisioning setting data + *AutoProvisioningSettingProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutoProvisioningSetting. +func (aps AutoProvisioningSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aps.AutoProvisioningSettingProperties != nil { + objectMap["properties"] = aps.AutoProvisioningSettingProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AutoProvisioningSetting struct. +func (aps *AutoProvisioningSetting) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var autoProvisioningSettingProperties AutoProvisioningSettingProperties + err = json.Unmarshal(*v, &autoProvisioningSettingProperties) + if err != nil { + return err + } + aps.AutoProvisioningSettingProperties = &autoProvisioningSettingProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + aps.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + aps.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + aps.Type = &typeVar + } + } + } + + return nil +} + +// AutoProvisioningSettingList list of all the auto provisioning settings response +type AutoProvisioningSettingList struct { + autorest.Response `json:"-"` + // Value - List of all the auto provisioning settings + Value *[]AutoProvisioningSetting `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutoProvisioningSettingList. +func (apsl AutoProvisioningSettingList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if apsl.Value != nil { + objectMap["value"] = apsl.Value + } + return json.Marshal(objectMap) +} + +// AutoProvisioningSettingListIterator provides access to a complete listing of AutoProvisioningSetting values. +type AutoProvisioningSettingListIterator struct { + i int + page AutoProvisioningSettingListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AutoProvisioningSettingListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoProvisioningSettingListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AutoProvisioningSettingListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AutoProvisioningSettingListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AutoProvisioningSettingListIterator) Response() AutoProvisioningSettingList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AutoProvisioningSettingListIterator) Value() AutoProvisioningSetting { + if !iter.page.NotDone() { + return AutoProvisioningSetting{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AutoProvisioningSettingListIterator type. +func NewAutoProvisioningSettingListIterator(page AutoProvisioningSettingListPage) AutoProvisioningSettingListIterator { + return AutoProvisioningSettingListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (apsl AutoProvisioningSettingList) IsEmpty() bool { + return apsl.Value == nil || len(*apsl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (apsl AutoProvisioningSettingList) hasNextLink() bool { + return apsl.NextLink != nil && len(*apsl.NextLink) != 0 +} + +// autoProvisioningSettingListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (apsl AutoProvisioningSettingList) autoProvisioningSettingListPreparer(ctx context.Context) (*http.Request, error) { + if !apsl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(apsl.NextLink))) +} + +// AutoProvisioningSettingListPage contains a page of AutoProvisioningSetting values. +type AutoProvisioningSettingListPage struct { + fn func(context.Context, AutoProvisioningSettingList) (AutoProvisioningSettingList, error) + apsl AutoProvisioningSettingList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AutoProvisioningSettingListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoProvisioningSettingListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.apsl) + if err != nil { + return err + } + page.apsl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AutoProvisioningSettingListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AutoProvisioningSettingListPage) NotDone() bool { + return !page.apsl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AutoProvisioningSettingListPage) Response() AutoProvisioningSettingList { + return page.apsl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AutoProvisioningSettingListPage) Values() []AutoProvisioningSetting { + if page.apsl.IsEmpty() { + return nil + } + return *page.apsl.Value +} + +// Creates a new instance of the AutoProvisioningSettingListPage type. +func NewAutoProvisioningSettingListPage(getNextPage func(context.Context, AutoProvisioningSettingList) (AutoProvisioningSettingList, error)) AutoProvisioningSettingListPage { + return AutoProvisioningSettingListPage{fn: getNextPage} +} + +// AutoProvisioningSettingProperties describes properties of an auto provisioning setting +type AutoProvisioningSettingProperties struct { + // AutoProvision - Describes what kind of security agent provisioning action to take. Possible values include: 'AutoProvisionOn', 'AutoProvisionOff' + AutoProvision AutoProvision `json:"autoProvision,omitempty"` +} + +// AwAssumeRoleAuthenticationDetailsProperties AWS cloud account connector based assume role, the role enables +// delegating access to your AWS resources. The role is composed of role arn and external id, for more details, +// refer to Creating a +// Role to Delegate Permissions to an IAM User (write only) +type AwAssumeRoleAuthenticationDetailsProperties struct { + // AccountID - READ-ONLY; The ID of the cloud account + AccountID *string `json:"accountId,omitempty"` + // AwsAssumeRoleArn - Assumed role ID is an identifier that you can use to create temporary security credentials. + AwsAssumeRoleArn *string `json:"awsAssumeRoleArn,omitempty"` + // AwsExternalID - A unique identifier that is required when you assume a role in another account. + AwsExternalID *string `json:"awsExternalId,omitempty"` + // AuthenticationProvisioningState - READ-ONLY; State of the multi-cloud connector. Possible values include: 'Valid', 'Invalid', 'Expired', 'IncorrectPolicy' + AuthenticationProvisioningState AuthenticationProvisioningState `json:"authenticationProvisioningState,omitempty"` + // GrantedPermissions - READ-ONLY; The permissions detected in the cloud account. + GrantedPermissions *[]PermissionProperty `json:"grantedPermissions,omitempty"` + // AuthenticationType - Possible values include: 'AuthenticationTypeAuthenticationDetailsProperties', 'AuthenticationTypeAwsCreds', 'AuthenticationTypeAwsAssumeRole', 'AuthenticationTypeGcpCredentials' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AwAssumeRoleAuthenticationDetailsProperties. +func (aaradp AwAssumeRoleAuthenticationDetailsProperties) MarshalJSON() ([]byte, error) { + aaradp.AuthenticationType = AuthenticationTypeAwsAssumeRole + objectMap := make(map[string]interface{}) + if aaradp.AwsAssumeRoleArn != nil { + objectMap["awsAssumeRoleArn"] = aaradp.AwsAssumeRoleArn + } + if aaradp.AwsExternalID != nil { + objectMap["awsExternalId"] = aaradp.AwsExternalID + } + if aaradp.AuthenticationType != "" { + objectMap["authenticationType"] = aaradp.AuthenticationType + } + return json.Marshal(objectMap) +} + +// AsAwsCredsAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AwAssumeRoleAuthenticationDetailsProperties. +func (aaradp AwAssumeRoleAuthenticationDetailsProperties) AsAwsCredsAuthenticationDetailsProperties() (*AwsCredsAuthenticationDetailsProperties, bool) { + return nil, false +} + +// AsAwAssumeRoleAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AwAssumeRoleAuthenticationDetailsProperties. +func (aaradp AwAssumeRoleAuthenticationDetailsProperties) AsAwAssumeRoleAuthenticationDetailsProperties() (*AwAssumeRoleAuthenticationDetailsProperties, bool) { + return &aaradp, true +} + +// AsGcpCredentialsDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AwAssumeRoleAuthenticationDetailsProperties. +func (aaradp AwAssumeRoleAuthenticationDetailsProperties) AsGcpCredentialsDetailsProperties() (*GcpCredentialsDetailsProperties, bool) { + return nil, false +} + +// AsAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AwAssumeRoleAuthenticationDetailsProperties. +func (aaradp AwAssumeRoleAuthenticationDetailsProperties) AsAuthenticationDetailsProperties() (*AuthenticationDetailsProperties, bool) { + return nil, false +} + +// AsBasicAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AwAssumeRoleAuthenticationDetailsProperties. +func (aaradp AwAssumeRoleAuthenticationDetailsProperties) AsBasicAuthenticationDetailsProperties() (BasicAuthenticationDetailsProperties, bool) { + return &aaradp, true +} + +// AwsCredsAuthenticationDetailsProperties AWS cloud account connector based credentials, the credentials is +// composed of access key id and secret key, for more details, refer to Creating an IAM User in Your +// AWS Account (write only) +type AwsCredsAuthenticationDetailsProperties struct { + // AccountID - READ-ONLY; The ID of the cloud account + AccountID *string `json:"accountId,omitempty"` + // AwsAccessKeyID - Public key element of the AWS credential object (write only) + AwsAccessKeyID *string `json:"awsAccessKeyId,omitempty"` + // AwsSecretAccessKey - Secret key element of the AWS credential object (write only) + AwsSecretAccessKey *string `json:"awsSecretAccessKey,omitempty"` + // AuthenticationProvisioningState - READ-ONLY; State of the multi-cloud connector. Possible values include: 'Valid', 'Invalid', 'Expired', 'IncorrectPolicy' + AuthenticationProvisioningState AuthenticationProvisioningState `json:"authenticationProvisioningState,omitempty"` + // GrantedPermissions - READ-ONLY; The permissions detected in the cloud account. + GrantedPermissions *[]PermissionProperty `json:"grantedPermissions,omitempty"` + // AuthenticationType - Possible values include: 'AuthenticationTypeAuthenticationDetailsProperties', 'AuthenticationTypeAwsCreds', 'AuthenticationTypeAwsAssumeRole', 'AuthenticationTypeGcpCredentials' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AwsCredsAuthenticationDetailsProperties. +func (acadp AwsCredsAuthenticationDetailsProperties) MarshalJSON() ([]byte, error) { + acadp.AuthenticationType = AuthenticationTypeAwsCreds + objectMap := make(map[string]interface{}) + if acadp.AwsAccessKeyID != nil { + objectMap["awsAccessKeyId"] = acadp.AwsAccessKeyID + } + if acadp.AwsSecretAccessKey != nil { + objectMap["awsSecretAccessKey"] = acadp.AwsSecretAccessKey + } + if acadp.AuthenticationType != "" { + objectMap["authenticationType"] = acadp.AuthenticationType + } + return json.Marshal(objectMap) +} + +// AsAwsCredsAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AwsCredsAuthenticationDetailsProperties. +func (acadp AwsCredsAuthenticationDetailsProperties) AsAwsCredsAuthenticationDetailsProperties() (*AwsCredsAuthenticationDetailsProperties, bool) { + return &acadp, true +} + +// AsAwAssumeRoleAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AwsCredsAuthenticationDetailsProperties. +func (acadp AwsCredsAuthenticationDetailsProperties) AsAwAssumeRoleAuthenticationDetailsProperties() (*AwAssumeRoleAuthenticationDetailsProperties, bool) { + return nil, false +} + +// AsGcpCredentialsDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AwsCredsAuthenticationDetailsProperties. +func (acadp AwsCredsAuthenticationDetailsProperties) AsGcpCredentialsDetailsProperties() (*GcpCredentialsDetailsProperties, bool) { + return nil, false +} + +// AsAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AwsCredsAuthenticationDetailsProperties. +func (acadp AwsCredsAuthenticationDetailsProperties) AsAuthenticationDetailsProperties() (*AuthenticationDetailsProperties, bool) { + return nil, false +} + +// AsBasicAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for AwsCredsAuthenticationDetailsProperties. +func (acadp AwsCredsAuthenticationDetailsProperties) AsBasicAuthenticationDetailsProperties() (BasicAuthenticationDetailsProperties, bool) { + return &acadp, true +} + +// AzureResourceDetails details of the Azure resource that was assessed +type AzureResourceDetails struct { + // ID - READ-ONLY; Azure resource Id of the assessed resource + ID *string `json:"id,omitempty"` + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremiseSQL', 'SourceOnPremise', 'SourceAzure' + Source Source `json:"source,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureResourceDetails. +func (ard AzureResourceDetails) MarshalJSON() ([]byte, error) { + ard.Source = SourceAzure + objectMap := make(map[string]interface{}) + if ard.Source != "" { + objectMap["source"] = ard.Source + } + return json.Marshal(objectMap) +} + +// AsOnPremiseSQLResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. +func (ard AzureResourceDetails) AsOnPremiseSQLResourceDetails() (*OnPremiseSQLResourceDetails, bool) { + return nil, false +} + +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. +func (ard AzureResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { + return nil, false +} + +// AsBasicOnPremiseResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. +func (ard AzureResourceDetails) AsBasicOnPremiseResourceDetails() (BasicOnPremiseResourceDetails, bool) { + return nil, false +} + +// AsAzureResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. +func (ard AzureResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { + return &ard, true +} + +// AsResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. +func (ard AzureResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { + return nil, false +} + +// AsBasicResourceDetails is the BasicResourceDetails implementation for AzureResourceDetails. +func (ard AzureResourceDetails) AsBasicResourceDetails() (BasicResourceDetails, bool) { + return &ard, true +} + +// AzureResourceLink describes an Azure resource with kind +type AzureResourceLink struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` +} + +// CefExternalSecuritySolution represents a security solution which sends CEF logs to an OMS workspace +type CefExternalSecuritySolution struct { + Properties *CefSolutionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + // Kind - Possible values include: 'KindExternalSecuritySolution', 'KindCEF', 'KindATA', 'KindAAD' + Kind KindEnum1 `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for CefExternalSecuritySolution. +func (cess CefExternalSecuritySolution) MarshalJSON() ([]byte, error) { + cess.Kind = KindCEF + objectMap := make(map[string]interface{}) + if cess.Properties != nil { + objectMap["properties"] = cess.Properties + } + if cess.Kind != "" { + objectMap["kind"] = cess.Kind + } + return json.Marshal(objectMap) +} + +// AsCefExternalSecuritySolution is the BasicExternalSecuritySolution implementation for CefExternalSecuritySolution. +func (cess CefExternalSecuritySolution) AsCefExternalSecuritySolution() (*CefExternalSecuritySolution, bool) { + return &cess, true +} + +// AsAtaExternalSecuritySolution is the BasicExternalSecuritySolution implementation for CefExternalSecuritySolution. +func (cess CefExternalSecuritySolution) AsAtaExternalSecuritySolution() (*AtaExternalSecuritySolution, bool) { + return nil, false +} + +// AsAadExternalSecuritySolution is the BasicExternalSecuritySolution implementation for CefExternalSecuritySolution. +func (cess CefExternalSecuritySolution) AsAadExternalSecuritySolution() (*AadExternalSecuritySolution, bool) { + return nil, false +} + +// AsExternalSecuritySolution is the BasicExternalSecuritySolution implementation for CefExternalSecuritySolution. +func (cess CefExternalSecuritySolution) AsExternalSecuritySolution() (*ExternalSecuritySolution, bool) { + return nil, false +} + +// AsBasicExternalSecuritySolution is the BasicExternalSecuritySolution implementation for CefExternalSecuritySolution. +func (cess CefExternalSecuritySolution) AsBasicExternalSecuritySolution() (BasicExternalSecuritySolution, bool) { + return &cess, true +} + +// CefSolutionProperties ... +type CefSolutionProperties struct { + Hostname *string `json:"hostname,omitempty"` + Agent *string `json:"agent,omitempty"` + LastEventReceived *string `json:"lastEventReceived,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + DeviceVendor *string `json:"deviceVendor,omitempty"` + DeviceType *string `json:"deviceType,omitempty"` + Workspace *ConnectedWorkspace `json:"workspace,omitempty"` +} + +// MarshalJSON is the custom marshaler for CefSolutionProperties. +func (csp CefSolutionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if csp.Hostname != nil { + objectMap["hostname"] = csp.Hostname + } + if csp.Agent != nil { + objectMap["agent"] = csp.Agent + } + if csp.LastEventReceived != nil { + objectMap["lastEventReceived"] = csp.LastEventReceived + } + if csp.DeviceVendor != nil { + objectMap["deviceVendor"] = csp.DeviceVendor + } + if csp.DeviceType != nil { + objectMap["deviceType"] = csp.DeviceType + } + if csp.Workspace != nil { + objectMap["workspace"] = csp.Workspace + } + for k, v := range csp.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CefSolutionProperties struct. +func (csp *CefSolutionProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "hostname": + if v != nil { + var hostname string + err = json.Unmarshal(*v, &hostname) + if err != nil { + return err + } + csp.Hostname = &hostname + } + case "agent": + if v != nil { + var agent string + err = json.Unmarshal(*v, &agent) + if err != nil { + return err + } + csp.Agent = &agent + } + case "lastEventReceived": + if v != nil { + var lastEventReceived string + err = json.Unmarshal(*v, &lastEventReceived) + if err != nil { + return err + } + csp.LastEventReceived = &lastEventReceived + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if csp.AdditionalProperties == nil { + csp.AdditionalProperties = make(map[string]interface{}) + } + csp.AdditionalProperties[k] = additionalProperties + } + case "deviceVendor": + if v != nil { + var deviceVendor string + err = json.Unmarshal(*v, &deviceVendor) + if err != nil { + return err + } + csp.DeviceVendor = &deviceVendor + } + case "deviceType": + if v != nil { + var deviceType string + err = json.Unmarshal(*v, &deviceType) + if err != nil { + return err + } + csp.DeviceType = &deviceType + } + case "workspace": + if v != nil { + var workspace ConnectedWorkspace + err = json.Unmarshal(*v, &workspace) + if err != nil { + return err + } + csp.Workspace = &workspace + } + } + } + + return nil +} + +// CloudError error response structure. +type CloudError struct { + // CloudErrorBody - Error data + *CloudErrorBody `json:"error,omitempty"` +} + +// MarshalJSON is the custom marshaler for CloudError. +func (ce CloudError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ce.CloudErrorBody != nil { + objectMap["error"] = ce.CloudErrorBody + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CloudError struct. +func (ce *CloudError) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "error": + if v != nil { + var cloudErrorBody CloudErrorBody + err = json.Unmarshal(*v, &cloudErrorBody) + if err != nil { + return err + } + ce.CloudErrorBody = &cloudErrorBody + } + } + } + + return nil +} + +// CloudErrorBody error details. +type CloudErrorBody struct { + // Code - READ-ONLY; An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` +} + +// Compliance compliance of a scope +type Compliance struct { + autorest.Response `json:"-"` + // ComplianceProperties - Compliance data + *ComplianceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Compliance. +func (c Compliance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.ComplianceProperties != nil { + objectMap["properties"] = c.ComplianceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Compliance struct. +func (c *Compliance) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var complianceProperties ComplianceProperties + err = json.Unmarshal(*v, &complianceProperties) + if err != nil { + return err + } + c.ComplianceProperties = &complianceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ComplianceList list of Compliance objects response +type ComplianceList struct { + autorest.Response `json:"-"` + // Value - List of Compliance objects + Value *[]Compliance `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ComplianceList. +func (cl ComplianceList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cl.Value != nil { + objectMap["value"] = cl.Value + } + return json.Marshal(objectMap) +} + +// ComplianceListIterator provides access to a complete listing of Compliance values. +type ComplianceListIterator struct { + i int + page ComplianceListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ComplianceListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComplianceListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ComplianceListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ComplianceListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ComplianceListIterator) Response() ComplianceList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ComplianceListIterator) Value() Compliance { + if !iter.page.NotDone() { + return Compliance{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ComplianceListIterator type. +func NewComplianceListIterator(page ComplianceListPage) ComplianceListIterator { + return ComplianceListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cl ComplianceList) IsEmpty() bool { + return cl.Value == nil || len(*cl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cl ComplianceList) hasNextLink() bool { + return cl.NextLink != nil && len(*cl.NextLink) != 0 +} + +// complianceListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cl ComplianceList) complianceListPreparer(ctx context.Context) (*http.Request, error) { + if !cl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cl.NextLink))) +} + +// ComplianceListPage contains a page of Compliance values. +type ComplianceListPage struct { + fn func(context.Context, ComplianceList) (ComplianceList, error) + cl ComplianceList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ComplianceListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComplianceListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cl) + if err != nil { + return err + } + page.cl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ComplianceListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ComplianceListPage) NotDone() bool { + return !page.cl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ComplianceListPage) Response() ComplianceList { + return page.cl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ComplianceListPage) Values() []Compliance { + if page.cl.IsEmpty() { + return nil + } + return *page.cl.Value +} + +// Creates a new instance of the ComplianceListPage type. +func NewComplianceListPage(getNextPage func(context.Context, ComplianceList) (ComplianceList, error)) ComplianceListPage { + return ComplianceListPage{fn: getNextPage} +} + +// ComplianceProperties the Compliance score (percentage) of a Subscription is a sum of all Resources' +// Compliances under the given Subscription. A Resource Compliance is defined as the compliant ('healthy') +// Policy Definitions out of all Policy Definitions applicable to a given resource. +type ComplianceProperties struct { + // AssessmentTimestampUtcDate - READ-ONLY; The timestamp when the Compliance calculation was conducted. + AssessmentTimestampUtcDate *date.Time `json:"assessmentTimestampUtcDate,omitempty"` + // ResourceCount - READ-ONLY; The resource count of the given subscription for which the Compliance calculation was conducted (needed for Management Group Compliance calculation). + ResourceCount *int32 `json:"resourceCount,omitempty"` + // AssessmentResult - READ-ONLY; An array of segment, which is the actually the compliance assessment. + AssessmentResult *[]ComplianceSegment `json:"assessmentResult,omitempty"` +} + +// ComplianceResult a compliance result +type ComplianceResult struct { + autorest.Response `json:"-"` + // ComplianceResultProperties - Compliance result data + *ComplianceResultProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ComplianceResult. +func (cr ComplianceResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cr.ComplianceResultProperties != nil { + objectMap["properties"] = cr.ComplianceResultProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ComplianceResult struct. +func (cr *ComplianceResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var complianceResultProperties ComplianceResultProperties + err = json.Unmarshal(*v, &complianceResultProperties) + if err != nil { + return err + } + cr.ComplianceResultProperties = &complianceResultProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cr.Type = &typeVar + } + } + } + + return nil +} + +// ComplianceResultList list of compliance results response +type ComplianceResultList struct { + autorest.Response `json:"-"` + // Value - List of compliance results + Value *[]ComplianceResult `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ComplianceResultList. +func (crl ComplianceResultList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if crl.Value != nil { + objectMap["value"] = crl.Value + } + return json.Marshal(objectMap) +} + +// ComplianceResultListIterator provides access to a complete listing of ComplianceResult values. +type ComplianceResultListIterator struct { + i int + page ComplianceResultListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ComplianceResultListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComplianceResultListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ComplianceResultListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ComplianceResultListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ComplianceResultListIterator) Response() ComplianceResultList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ComplianceResultListIterator) Value() ComplianceResult { + if !iter.page.NotDone() { + return ComplianceResult{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ComplianceResultListIterator type. +func NewComplianceResultListIterator(page ComplianceResultListPage) ComplianceResultListIterator { + return ComplianceResultListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (crl ComplianceResultList) IsEmpty() bool { + return crl.Value == nil || len(*crl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (crl ComplianceResultList) hasNextLink() bool { + return crl.NextLink != nil && len(*crl.NextLink) != 0 +} + +// complianceResultListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (crl ComplianceResultList) complianceResultListPreparer(ctx context.Context) (*http.Request, error) { + if !crl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(crl.NextLink))) +} + +// ComplianceResultListPage contains a page of ComplianceResult values. +type ComplianceResultListPage struct { + fn func(context.Context, ComplianceResultList) (ComplianceResultList, error) + crl ComplianceResultList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ComplianceResultListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ComplianceResultListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.crl) + if err != nil { + return err + } + page.crl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ComplianceResultListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ComplianceResultListPage) NotDone() bool { + return !page.crl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ComplianceResultListPage) Response() ComplianceResultList { + return page.crl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ComplianceResultListPage) Values() []ComplianceResult { + if page.crl.IsEmpty() { + return nil + } + return *page.crl.Value +} + +// Creates a new instance of the ComplianceResultListPage type. +func NewComplianceResultListPage(getNextPage func(context.Context, ComplianceResultList) (ComplianceResultList, error)) ComplianceResultListPage { + return ComplianceResultListPage{fn: getNextPage} +} + +// ComplianceResultProperties compliance result data +type ComplianceResultProperties struct { + // ResourceStatus - READ-ONLY; The status of the resource regarding a single assessment. Possible values include: 'ResourceStatusHealthy', 'ResourceStatusNotApplicable', 'ResourceStatusOffByPolicy', 'ResourceStatusNotHealthy' + ResourceStatus ResourceStatus `json:"resourceStatus,omitempty"` +} + +// ComplianceSegment a segment of a compliance assessment. +type ComplianceSegment struct { + // SegmentType - READ-ONLY; The segment type, e.g. compliant, non-compliance, insufficient coverage, N/A, etc. + SegmentType *string `json:"segmentType,omitempty"` + // Percentage - READ-ONLY; The size (%) of the segment. + Percentage *float64 `json:"percentage,omitempty"` +} + +// ConnectableResource describes the allowed inbound and outbound traffic of an Azure resource +type ConnectableResource struct { + // ID - READ-ONLY; The Azure resource id + ID *string `json:"id,omitempty"` + // InboundConnectedResources - READ-ONLY; The list of Azure resources that the resource has inbound allowed connection from + InboundConnectedResources *[]ConnectedResource `json:"inboundConnectedResources,omitempty"` + // OutboundConnectedResources - READ-ONLY; The list of Azure resources that the resource has outbound allowed connection to + OutboundConnectedResources *[]ConnectedResource `json:"outboundConnectedResources,omitempty"` +} + +// ConnectedResource describes properties of a connected resource +type ConnectedResource struct { + // ConnectedResourceID - READ-ONLY; The Azure resource id of the connected resource + ConnectedResourceID *string `json:"connectedResourceId,omitempty"` + // TCPPorts - READ-ONLY; The allowed tcp ports + TCPPorts *string `json:"tcpPorts,omitempty"` + // UDPPorts - READ-ONLY; The allowed udp ports + UDPPorts *string `json:"udpPorts,omitempty"` +} + +// ConnectedWorkspace ... +type ConnectedWorkspace struct { + // ID - Azure resource ID of the connected OMS workspace + ID *string `json:"id,omitempty"` +} + +// ConnectionToIPNotAllowed outbound connection to an ip that isn't allowed. Allow list consists of ipv4 or +// ipv6 range in CIDR notation. +type ConnectionToIPNotAllowed struct { + // AllowlistValues - The values to allow. The format of the values depends on the rule type. + AllowlistValues *[]string `json:"allowlistValues,omitempty"` + // ValueType - READ-ONLY; The value type of the items in the list. Possible values include: 'ValueTypeIPCidr', 'ValueTypeString' + ValueType ValueType `json:"valueType,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) MarshalJSON() ([]byte, error) { + ctina.RuleType = RuleTypeConnectionToIPNotAllowed + objectMap := make(map[string]interface{}) + if ctina.AllowlistValues != nil { + objectMap["allowlistValues"] = ctina.AllowlistValues + } + if ctina.IsEnabled != nil { + objectMap["isEnabled"] = ctina.IsEnabled + } + if ctina.RuleType != "" { + objectMap["ruleType"] = ctina.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return &ctina, true +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return &ctina, true +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return &ctina, true +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for ConnectionToIPNotAllowed. +func (ctina ConnectionToIPNotAllowed) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &ctina, true +} + +// ConnectorSetting the connector setting +type ConnectorSetting struct { + autorest.Response `json:"-"` + // ConnectorSettingProperties - Connector setting data + *ConnectorSettingProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectorSetting. +func (cs ConnectorSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cs.ConnectorSettingProperties != nil { + objectMap["properties"] = cs.ConnectorSettingProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectorSetting struct. +func (cs *ConnectorSetting) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var connectorSettingProperties ConnectorSettingProperties + err = json.Unmarshal(*v, &connectorSettingProperties) + if err != nil { + return err + } + cs.ConnectorSettingProperties = &connectorSettingProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cs.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cs.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cs.Type = &typeVar + } + } + } + + return nil +} + +// ConnectorSettingList for a subscription, list of all cloud account connectors and their settings +type ConnectorSettingList struct { + autorest.Response `json:"-"` + // Value - List of all the cloud account connector settings + Value *[]ConnectorSetting `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectorSettingList. +func (csl ConnectorSettingList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if csl.Value != nil { + objectMap["value"] = csl.Value + } + return json.Marshal(objectMap) +} + +// ConnectorSettingListIterator provides access to a complete listing of ConnectorSetting values. +type ConnectorSettingListIterator struct { + i int + page ConnectorSettingListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ConnectorSettingListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectorSettingListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ConnectorSettingListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConnectorSettingListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ConnectorSettingListIterator) Response() ConnectorSettingList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ConnectorSettingListIterator) Value() ConnectorSetting { + if !iter.page.NotDone() { + return ConnectorSetting{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ConnectorSettingListIterator type. +func NewConnectorSettingListIterator(page ConnectorSettingListPage) ConnectorSettingListIterator { + return ConnectorSettingListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (csl ConnectorSettingList) IsEmpty() bool { + return csl.Value == nil || len(*csl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (csl ConnectorSettingList) hasNextLink() bool { + return csl.NextLink != nil && len(*csl.NextLink) != 0 +} + +// connectorSettingListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (csl ConnectorSettingList) connectorSettingListPreparer(ctx context.Context) (*http.Request, error) { + if !csl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(csl.NextLink))) +} + +// ConnectorSettingListPage contains a page of ConnectorSetting values. +type ConnectorSettingListPage struct { + fn func(context.Context, ConnectorSettingList) (ConnectorSettingList, error) + csl ConnectorSettingList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ConnectorSettingListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectorSettingListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.csl) + if err != nil { + return err + } + page.csl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ConnectorSettingListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConnectorSettingListPage) NotDone() bool { + return !page.csl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConnectorSettingListPage) Response() ConnectorSettingList { + return page.csl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConnectorSettingListPage) Values() []ConnectorSetting { + if page.csl.IsEmpty() { + return nil + } + return *page.csl.Value +} + +// Creates a new instance of the ConnectorSettingListPage type. +func NewConnectorSettingListPage(getNextPage func(context.Context, ConnectorSettingList) (ConnectorSettingList, error)) ConnectorSettingListPage { + return ConnectorSettingListPage{fn: getNextPage} +} + +// ConnectorSettingProperties describes properties of an connector setting +type ConnectorSettingProperties struct { + // HybridComputeSettings - Settings for hybrid compute management, these settings are relevant only Arc autoProvision (Hybrid Compute). + HybridComputeSettings *HybridComputeSettingsProperties `json:"hybridComputeSettings,omitempty"` + // AuthenticationDetails - Settings for authentication management, these settings are relevant only for the cloud connector. + AuthenticationDetails BasicAuthenticationDetailsProperties `json:"authenticationDetails,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for ConnectorSettingProperties struct. +func (csp *ConnectorSettingProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "hybridComputeSettings": + if v != nil { + var hybridComputeSettings HybridComputeSettingsProperties + err = json.Unmarshal(*v, &hybridComputeSettings) + if err != nil { + return err + } + csp.HybridComputeSettings = &hybridComputeSettings + } + case "authenticationDetails": + if v != nil { + authenticationDetails, err := unmarshalBasicAuthenticationDetailsProperties(*v) + if err != nil { + return err + } + csp.AuthenticationDetails = authenticationDetails + } + } + } + + return nil +} + +// Contact contact details for security issues +type Contact struct { + autorest.Response `json:"-"` + // ContactProperties - Security contact data + *ContactProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Contact. +func (c Contact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.ContactProperties != nil { + objectMap["properties"] = c.ContactProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Contact struct. +func (c *Contact) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var contactProperties ContactProperties + err = json.Unmarshal(*v, &contactProperties) + if err != nil { + return err + } + c.ContactProperties = &contactProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ContactList list of security contacts response +type ContactList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of security contacts + Value *[]Contact `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// ContactListIterator provides access to a complete listing of Contact values. +type ContactListIterator struct { + i int + page ContactListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ContactListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContactListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ContactListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ContactListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ContactListIterator) Response() ContactList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ContactListIterator) Value() Contact { + if !iter.page.NotDone() { + return Contact{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ContactListIterator type. +func NewContactListIterator(page ContactListPage) ContactListIterator { + return ContactListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cl ContactList) IsEmpty() bool { + return cl.Value == nil || len(*cl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cl ContactList) hasNextLink() bool { + return cl.NextLink != nil && len(*cl.NextLink) != 0 +} + +// contactListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cl ContactList) contactListPreparer(ctx context.Context) (*http.Request, error) { + if !cl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cl.NextLink))) +} + +// ContactListPage contains a page of Contact values. +type ContactListPage struct { + fn func(context.Context, ContactList) (ContactList, error) + cl ContactList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ContactListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ContactListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cl) + if err != nil { + return err + } + page.cl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ContactListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ContactListPage) NotDone() bool { + return !page.cl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ContactListPage) Response() ContactList { + return page.cl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ContactListPage) Values() []Contact { + if page.cl.IsEmpty() { + return nil + } + return *page.cl.Value +} + +// Creates a new instance of the ContactListPage type. +func NewContactListPage(getNextPage func(context.Context, ContactList) (ContactList, error)) ContactListPage { + return ContactListPage{fn: getNextPage} +} + +// ContactProperties describes security contact properties +type ContactProperties struct { + // Email - The email of this security contact + Email *string `json:"email,omitempty"` + // Phone - The phone number of this security contact + Phone *string `json:"phone,omitempty"` + // AlertNotifications - Whether to send security alerts notifications to the security contact. Possible values include: 'On', 'Off' + AlertNotifications AlertNotifications `json:"alertNotifications,omitempty"` + // AlertsToAdmins - Whether to send security alerts notifications to subscription admins. Possible values include: 'AlertsToAdminsOn', 'AlertsToAdminsOff' + AlertsToAdmins AlertsToAdmins `json:"alertsToAdmins,omitempty"` +} + +// ContainerRegistryVulnerabilityProperties additional context fields for container registry Vulnerability +// assessment +type ContainerRegistryVulnerabilityProperties struct { + // Type - READ-ONLY; Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information Gathered, Vulnerability + Type *string `json:"type,omitempty"` + // Cvss - READ-ONLY; Dictionary from cvss version to cvss details object + Cvss map[string]*CVSS `json:"cvss"` + // Patchable - READ-ONLY; Indicates whether a patch is available or not + Patchable *bool `json:"patchable,omitempty"` + // Cve - READ-ONLY; List of CVEs + Cve *[]CVE `json:"cve,omitempty"` + // PublishedTime - READ-ONLY; Published time + PublishedTime *date.Time `json:"publishedTime,omitempty"` + // VendorReferences - READ-ONLY + VendorReferences *[]VendorReference `json:"vendorReferences,omitempty"` + // RepositoryName - READ-ONLY; Name of the repository which the vulnerable image belongs to + RepositoryName *string `json:"repositoryName,omitempty"` + // ImageDigest - READ-ONLY; Digest of the vulnerable image + ImageDigest *string `json:"imageDigest,omitempty"` + // AssessedResourceType - Possible values include: 'AssessedResourceTypeAdditionalData', 'AssessedResourceTypeSQLServerVulnerability', 'AssessedResourceTypeContainerRegistryVulnerability', 'AssessedResourceTypeServerVulnerabilityAssessment' + AssessedResourceType AssessedResourceType `json:"assessedResourceType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ContainerRegistryVulnerabilityProperties. +func (crvp ContainerRegistryVulnerabilityProperties) MarshalJSON() ([]byte, error) { + crvp.AssessedResourceType = AssessedResourceTypeContainerRegistryVulnerability + objectMap := make(map[string]interface{}) + if crvp.AssessedResourceType != "" { + objectMap["assessedResourceType"] = crvp.AssessedResourceType + } + return json.Marshal(objectMap) +} + +// AsSQLServerVulnerabilityProperties is the BasicAdditionalData implementation for ContainerRegistryVulnerabilityProperties. +func (crvp ContainerRegistryVulnerabilityProperties) AsSQLServerVulnerabilityProperties() (*SQLServerVulnerabilityProperties, bool) { + return nil, false +} + +// AsContainerRegistryVulnerabilityProperties is the BasicAdditionalData implementation for ContainerRegistryVulnerabilityProperties. +func (crvp ContainerRegistryVulnerabilityProperties) AsContainerRegistryVulnerabilityProperties() (*ContainerRegistryVulnerabilityProperties, bool) { + return &crvp, true +} + +// AsServerVulnerabilityProperties is the BasicAdditionalData implementation for ContainerRegistryVulnerabilityProperties. +func (crvp ContainerRegistryVulnerabilityProperties) AsServerVulnerabilityProperties() (*ServerVulnerabilityProperties, bool) { + return nil, false +} + +// AsAdditionalData is the BasicAdditionalData implementation for ContainerRegistryVulnerabilityProperties. +func (crvp ContainerRegistryVulnerabilityProperties) AsAdditionalData() (*AdditionalData, bool) { + return nil, false +} + +// AsBasicAdditionalData is the BasicAdditionalData implementation for ContainerRegistryVulnerabilityProperties. +func (crvp ContainerRegistryVulnerabilityProperties) AsBasicAdditionalData() (BasicAdditionalData, bool) { + return &crvp, true +} + +// BasicCustomAlertRule a custom alert rule. +type BasicCustomAlertRule interface { + AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) + AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) + AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) + AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) + AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) + AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) + AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) + AsListCustomAlertRule() (*ListCustomAlertRule, bool) + AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) + AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) + AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) + AsProcessNotAllowed() (*ProcessNotAllowed, bool) + AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) + AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) + AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) + AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) + AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) + AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) + AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) + AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) + AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) + AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) + AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) + AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) + AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) + AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) + AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) + AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) + AsCustomAlertRule() (*CustomAlertRule, bool) +} + +// CustomAlertRule a custom alert rule. +type CustomAlertRule struct { + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +func unmarshalBasicCustomAlertRule(body []byte) (BasicCustomAlertRule, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["ruleType"] { + case string(RuleTypeThresholdCustomAlertRule): + var tcar ThresholdCustomAlertRule + err := json.Unmarshal(body, &tcar) + return tcar, err + case string(RuleTypeTimeWindowCustomAlertRule): + var twcar TimeWindowCustomAlertRule + err := json.Unmarshal(body, &twcar) + return twcar, err + case string(RuleTypeAllowlistCustomAlertRule): + var acar AllowlistCustomAlertRule + err := json.Unmarshal(body, &acar) + return acar, err + case string(RuleTypeDenylistCustomAlertRule): + var dcar DenylistCustomAlertRule + err := json.Unmarshal(body, &dcar) + return dcar, err + case string(RuleTypeListCustomAlertRule): + var lcar ListCustomAlertRule + err := json.Unmarshal(body, &lcar) + return lcar, err + case string(RuleTypeConnectionToIPNotAllowed): + var ctina ConnectionToIPNotAllowed + err := json.Unmarshal(body, &ctina) + return ctina, err + case string(RuleTypeLocalUserNotAllowed): + var luna LocalUserNotAllowed + err := json.Unmarshal(body, &luna) + return luna, err + case string(RuleTypeProcessNotAllowed): + var pna ProcessNotAllowed + err := json.Unmarshal(body, &pna) + return pna, err + case string(RuleTypeActiveConnectionsNotInAllowedRange): + var acniar ActiveConnectionsNotInAllowedRange + err := json.Unmarshal(body, &acniar) + return acniar, err + case string(RuleTypeAmqpC2DMessagesNotInAllowedRange): + var acmniar AmqpC2DMessagesNotInAllowedRange + err := json.Unmarshal(body, &acmniar) + return acmniar, err + case string(RuleTypeMqttC2DMessagesNotInAllowedRange): + var mcmniar MqttC2DMessagesNotInAllowedRange + err := json.Unmarshal(body, &mcmniar) + return mcmniar, err + case string(RuleTypeHTTPC2DMessagesNotInAllowedRange): + var hcmniar HTTPC2DMessagesNotInAllowedRange + err := json.Unmarshal(body, &hcmniar) + return hcmniar, err + case string(RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange): + var acrmniar AmqpC2DRejectedMessagesNotInAllowedRange + err := json.Unmarshal(body, &acrmniar) + return acrmniar, err + case string(RuleTypeMqttC2DRejectedMessagesNotInAllowedRange): + var mcrmniar MqttC2DRejectedMessagesNotInAllowedRange + err := json.Unmarshal(body, &mcrmniar) + return mcrmniar, err + case string(RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange): + var hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange + err := json.Unmarshal(body, &hcrmniar) + return hcrmniar, err + case string(RuleTypeAmqpD2CMessagesNotInAllowedRange): + var admniar AmqpD2CMessagesNotInAllowedRange + err := json.Unmarshal(body, &admniar) + return admniar, err + case string(RuleTypeMqttD2CMessagesNotInAllowedRange): + var mdmniar MqttD2CMessagesNotInAllowedRange + err := json.Unmarshal(body, &mdmniar) + return mdmniar, err + case string(RuleTypeHTTPD2CMessagesNotInAllowedRange): + var hdmniar HTTPD2CMessagesNotInAllowedRange + err := json.Unmarshal(body, &hdmniar) + return hdmniar, err + case string(RuleTypeDirectMethodInvokesNotInAllowedRange): + var dminiar DirectMethodInvokesNotInAllowedRange + err := json.Unmarshal(body, &dminiar) + return dminiar, err + case string(RuleTypeFailedLocalLoginsNotInAllowedRange): + var fllniar FailedLocalLoginsNotInAllowedRange + err := json.Unmarshal(body, &fllniar) + return fllniar, err + case string(RuleTypeFileUploadsNotInAllowedRange): + var funiar FileUploadsNotInAllowedRange + err := json.Unmarshal(body, &funiar) + return funiar, err + case string(RuleTypeQueuePurgesNotInAllowedRange): + var qpniar QueuePurgesNotInAllowedRange + err := json.Unmarshal(body, &qpniar) + return qpniar, err + case string(RuleTypeTwinUpdatesNotInAllowedRange): + var tuniar TwinUpdatesNotInAllowedRange + err := json.Unmarshal(body, &tuniar) + return tuniar, err + case string(RuleTypeUnauthorizedOperationsNotInAllowedRange): + var uoniar UnauthorizedOperationsNotInAllowedRange + err := json.Unmarshal(body, &uoniar) + return uoniar, err + default: + var car CustomAlertRule + err := json.Unmarshal(body, &car) + return car, err + } +} +func unmarshalBasicCustomAlertRuleArray(body []byte) ([]BasicCustomAlertRule, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + carArray := make([]BasicCustomAlertRule, len(rawMessages)) + + for index, rawMessage := range rawMessages { + car, err := unmarshalBasicCustomAlertRule(*rawMessage) + if err != nil { + return nil, err + } + carArray[index] = car + } + return carArray, nil +} + +// MarshalJSON is the custom marshaler for CustomAlertRule. +func (car CustomAlertRule) MarshalJSON() ([]byte, error) { + car.RuleType = RuleTypeCustomAlertRule + objectMap := make(map[string]interface{}) + if car.IsEnabled != nil { + objectMap["isEnabled"] = car.IsEnabled + } + if car.RuleType != "" { + objectMap["ruleType"] = car.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsCustomAlertRule() (*CustomAlertRule, bool) { + return &car, true +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for CustomAlertRule. +func (car CustomAlertRule) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &car, true +} + +// CVE CVE details +type CVE struct { + // Title - READ-ONLY; CVE title + Title *string `json:"title,omitempty"` + // Link - READ-ONLY; Link url + Link *string `json:"link,omitempty"` +} + +// CVSS CVSS details +type CVSS struct { + // Base - READ-ONLY; CVSS base + Base *float64 `json:"base,omitempty"` +} + +// DataExportSettingProperties the data export setting properties +type DataExportSettingProperties struct { + // Enabled - Is the data export setting is enabled + Enabled *bool `json:"enabled,omitempty"` +} + +// DataExportSettings represents a data export setting +type DataExportSettings struct { + // DataExportSettingProperties - Data export setting data + *DataExportSettingProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Kind - Possible values include: 'KindSettingResource', 'KindSetting', 'KindDataExportSettings' + Kind KindEnum `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataExportSettings. +func (desVar DataExportSettings) MarshalJSON() ([]byte, error) { + desVar.Kind = KindDataExportSettings + objectMap := make(map[string]interface{}) + if desVar.DataExportSettingProperties != nil { + objectMap["properties"] = desVar.DataExportSettingProperties + } + if desVar.Kind != "" { + objectMap["kind"] = desVar.Kind + } + return json.Marshal(objectMap) +} + +// AsSetting is the BasicSettingResource implementation for DataExportSettings. +func (desVar DataExportSettings) AsSetting() (*Setting, bool) { + return nil, false +} + +// AsBasicSetting is the BasicSettingResource implementation for DataExportSettings. +func (desVar DataExportSettings) AsBasicSetting() (BasicSetting, bool) { + return &desVar, true +} + +// AsDataExportSettings is the BasicSettingResource implementation for DataExportSettings. +func (desVar DataExportSettings) AsDataExportSettings() (*DataExportSettings, bool) { + return &desVar, true +} + +// AsSettingResource is the BasicSettingResource implementation for DataExportSettings. +func (desVar DataExportSettings) AsSettingResource() (*SettingResource, bool) { + return nil, false +} + +// AsBasicSettingResource is the BasicSettingResource implementation for DataExportSettings. +func (desVar DataExportSettings) AsBasicSettingResource() (BasicSettingResource, bool) { + return &desVar, true +} + +// UnmarshalJSON is the custom unmarshaler for DataExportSettings struct. +func (desVar *DataExportSettings) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dataExportSettingProperties DataExportSettingProperties + err = json.Unmarshal(*v, &dataExportSettingProperties) + if err != nil { + return err + } + desVar.DataExportSettingProperties = &dataExportSettingProperties + } + case "kind": + if v != nil { + var kind KindEnum + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + desVar.Kind = kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + desVar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + desVar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + desVar.Type = &typeVar + } + } + } + + return nil +} + +// DenylistCustomAlertRule a custom alert rule that checks if a value (depends on the custom alert type) is +// denied. +type DenylistCustomAlertRule struct { + // DenylistValues - The values to deny. The format of the values depends on the rule type. + DenylistValues *[]string `json:"denylistValues,omitempty"` + // ValueType - READ-ONLY; The value type of the items in the list. Possible values include: 'ValueTypeIPCidr', 'ValueTypeString' + ValueType ValueType `json:"valueType,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) MarshalJSON() ([]byte, error) { + dcar.RuleType = RuleTypeDenylistCustomAlertRule + objectMap := make(map[string]interface{}) + if dcar.DenylistValues != nil { + objectMap["denylistValues"] = dcar.DenylistValues + } + if dcar.IsEnabled != nil { + objectMap["isEnabled"] = dcar.IsEnabled + } + if dcar.RuleType != "" { + objectMap["ruleType"] = dcar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return &dcar, true +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return &dcar, true +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for DenylistCustomAlertRule. +func (dcar DenylistCustomAlertRule) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &dcar, true +} + +// DeviceSecurityGroup the device security group resource +type DeviceSecurityGroup struct { + autorest.Response `json:"-"` + // DeviceSecurityGroupProperties - Device Security group data + *DeviceSecurityGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeviceSecurityGroup. +func (dsg DeviceSecurityGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dsg.DeviceSecurityGroupProperties != nil { + objectMap["properties"] = dsg.DeviceSecurityGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DeviceSecurityGroup struct. +func (dsg *DeviceSecurityGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var deviceSecurityGroupProperties DeviceSecurityGroupProperties + err = json.Unmarshal(*v, &deviceSecurityGroupProperties) + if err != nil { + return err + } + dsg.DeviceSecurityGroupProperties = &deviceSecurityGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dsg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dsg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dsg.Type = &typeVar + } + } + } + + return nil +} + +// DeviceSecurityGroupList list of device security groups +type DeviceSecurityGroupList struct { + autorest.Response `json:"-"` + // Value - List of device security group objects + Value *[]DeviceSecurityGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeviceSecurityGroupList. +func (dsgl DeviceSecurityGroupList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dsgl.Value != nil { + objectMap["value"] = dsgl.Value + } + return json.Marshal(objectMap) +} + +// DeviceSecurityGroupListIterator provides access to a complete listing of DeviceSecurityGroup values. +type DeviceSecurityGroupListIterator struct { + i int + page DeviceSecurityGroupListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DeviceSecurityGroupListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSecurityGroupListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DeviceSecurityGroupListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DeviceSecurityGroupListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DeviceSecurityGroupListIterator) Response() DeviceSecurityGroupList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DeviceSecurityGroupListIterator) Value() DeviceSecurityGroup { + if !iter.page.NotDone() { + return DeviceSecurityGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DeviceSecurityGroupListIterator type. +func NewDeviceSecurityGroupListIterator(page DeviceSecurityGroupListPage) DeviceSecurityGroupListIterator { + return DeviceSecurityGroupListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dsgl DeviceSecurityGroupList) IsEmpty() bool { + return dsgl.Value == nil || len(*dsgl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dsgl DeviceSecurityGroupList) hasNextLink() bool { + return dsgl.NextLink != nil && len(*dsgl.NextLink) != 0 +} + +// deviceSecurityGroupListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dsgl DeviceSecurityGroupList) deviceSecurityGroupListPreparer(ctx context.Context) (*http.Request, error) { + if !dsgl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dsgl.NextLink))) +} + +// DeviceSecurityGroupListPage contains a page of DeviceSecurityGroup values. +type DeviceSecurityGroupListPage struct { + fn func(context.Context, DeviceSecurityGroupList) (DeviceSecurityGroupList, error) + dsgl DeviceSecurityGroupList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DeviceSecurityGroupListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeviceSecurityGroupListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dsgl) + if err != nil { + return err + } + page.dsgl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DeviceSecurityGroupListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DeviceSecurityGroupListPage) NotDone() bool { + return !page.dsgl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DeviceSecurityGroupListPage) Response() DeviceSecurityGroupList { + return page.dsgl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DeviceSecurityGroupListPage) Values() []DeviceSecurityGroup { + if page.dsgl.IsEmpty() { + return nil + } + return *page.dsgl.Value +} + +// Creates a new instance of the DeviceSecurityGroupListPage type. +func NewDeviceSecurityGroupListPage(getNextPage func(context.Context, DeviceSecurityGroupList) (DeviceSecurityGroupList, error)) DeviceSecurityGroupListPage { + return DeviceSecurityGroupListPage{fn: getNextPage} +} + +// DeviceSecurityGroupProperties describes properties of a security group. +type DeviceSecurityGroupProperties struct { + // ThresholdRules - The list of custom alert threshold rules. + ThresholdRules *[]BasicThresholdCustomAlertRule `json:"thresholdRules,omitempty"` + // TimeWindowRules - The list of custom alert time-window rules. + TimeWindowRules *[]BasicTimeWindowCustomAlertRule `json:"timeWindowRules,omitempty"` + // AllowlistRules - The allow-list custom alert rules. + AllowlistRules *[]BasicAllowlistCustomAlertRule `json:"allowlistRules,omitempty"` + // DenylistRules - The deny-list custom alert rules. + DenylistRules *[]DenylistCustomAlertRule `json:"denylistRules,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for DeviceSecurityGroupProperties struct. +func (dsgp *DeviceSecurityGroupProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "thresholdRules": + if v != nil { + thresholdRules, err := unmarshalBasicThresholdCustomAlertRuleArray(*v) + if err != nil { + return err + } + dsgp.ThresholdRules = &thresholdRules + } + case "timeWindowRules": + if v != nil { + timeWindowRules, err := unmarshalBasicTimeWindowCustomAlertRuleArray(*v) + if err != nil { + return err + } + dsgp.TimeWindowRules = &timeWindowRules + } + case "allowlistRules": + if v != nil { + allowlistRules, err := unmarshalBasicAllowlistCustomAlertRuleArray(*v) + if err != nil { + return err + } + dsgp.AllowlistRules = &allowlistRules + } + case "denylistRules": + if v != nil { + var denylistRules []DenylistCustomAlertRule + err = json.Unmarshal(*v, &denylistRules) + if err != nil { + return err + } + dsgp.DenylistRules = &denylistRules + } + } + } + + return nil +} + +// DirectMethodInvokesNotInAllowedRange number of direct method invokes is not in allowed range. +type DirectMethodInvokesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) MarshalJSON() ([]byte, error) { + dminiar.RuleType = RuleTypeDirectMethodInvokesNotInAllowedRange + objectMap := make(map[string]interface{}) + if dminiar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = dminiar.TimeWindowSize + } + if dminiar.MinThreshold != nil { + objectMap["minThreshold"] = dminiar.MinThreshold + } + if dminiar.MaxThreshold != nil { + objectMap["maxThreshold"] = dminiar.MaxThreshold + } + if dminiar.IsEnabled != nil { + objectMap["isEnabled"] = dminiar.IsEnabled + } + if dminiar.RuleType != "" { + objectMap["ruleType"] = dminiar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &dminiar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &dminiar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return &dminiar, true +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for DirectMethodInvokesNotInAllowedRange. +func (dminiar DirectMethodInvokesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &dminiar, true +} + +// DiscoveredSecuritySolution ... +type DiscoveredSecuritySolution struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + *DiscoveredSecuritySolutionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for DiscoveredSecuritySolution. +func (dss DiscoveredSecuritySolution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dss.DiscoveredSecuritySolutionProperties != nil { + objectMap["properties"] = dss.DiscoveredSecuritySolutionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DiscoveredSecuritySolution struct. +func (dss *DiscoveredSecuritySolution) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dss.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dss.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dss.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dss.Location = &location + } + case "properties": + if v != nil { + var discoveredSecuritySolutionProperties DiscoveredSecuritySolutionProperties + err = json.Unmarshal(*v, &discoveredSecuritySolutionProperties) + if err != nil { + return err + } + dss.DiscoveredSecuritySolutionProperties = &discoveredSecuritySolutionProperties + } + } + } + + return nil +} + +// DiscoveredSecuritySolutionList ... +type DiscoveredSecuritySolutionList struct { + autorest.Response `json:"-"` + Value *[]DiscoveredSecuritySolution `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DiscoveredSecuritySolutionList. +func (dssl DiscoveredSecuritySolutionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dssl.Value != nil { + objectMap["value"] = dssl.Value + } + return json.Marshal(objectMap) +} + +// DiscoveredSecuritySolutionListIterator provides access to a complete listing of DiscoveredSecuritySolution +// values. +type DiscoveredSecuritySolutionListIterator struct { + i int + page DiscoveredSecuritySolutionListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DiscoveredSecuritySolutionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiscoveredSecuritySolutionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DiscoveredSecuritySolutionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DiscoveredSecuritySolutionListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DiscoveredSecuritySolutionListIterator) Response() DiscoveredSecuritySolutionList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DiscoveredSecuritySolutionListIterator) Value() DiscoveredSecuritySolution { + if !iter.page.NotDone() { + return DiscoveredSecuritySolution{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DiscoveredSecuritySolutionListIterator type. +func NewDiscoveredSecuritySolutionListIterator(page DiscoveredSecuritySolutionListPage) DiscoveredSecuritySolutionListIterator { + return DiscoveredSecuritySolutionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dssl DiscoveredSecuritySolutionList) IsEmpty() bool { + return dssl.Value == nil || len(*dssl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dssl DiscoveredSecuritySolutionList) hasNextLink() bool { + return dssl.NextLink != nil && len(*dssl.NextLink) != 0 +} + +// discoveredSecuritySolutionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dssl DiscoveredSecuritySolutionList) discoveredSecuritySolutionListPreparer(ctx context.Context) (*http.Request, error) { + if !dssl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dssl.NextLink))) +} + +// DiscoveredSecuritySolutionListPage contains a page of DiscoveredSecuritySolution values. +type DiscoveredSecuritySolutionListPage struct { + fn func(context.Context, DiscoveredSecuritySolutionList) (DiscoveredSecuritySolutionList, error) + dssl DiscoveredSecuritySolutionList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DiscoveredSecuritySolutionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiscoveredSecuritySolutionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dssl) + if err != nil { + return err + } + page.dssl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DiscoveredSecuritySolutionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DiscoveredSecuritySolutionListPage) NotDone() bool { + return !page.dssl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DiscoveredSecuritySolutionListPage) Response() DiscoveredSecuritySolutionList { + return page.dssl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DiscoveredSecuritySolutionListPage) Values() []DiscoveredSecuritySolution { + if page.dssl.IsEmpty() { + return nil + } + return *page.dssl.Value +} + +// Creates a new instance of the DiscoveredSecuritySolutionListPage type. +func NewDiscoveredSecuritySolutionListPage(getNextPage func(context.Context, DiscoveredSecuritySolutionList) (DiscoveredSecuritySolutionList, error)) DiscoveredSecuritySolutionListPage { + return DiscoveredSecuritySolutionListPage{fn: getNextPage} +} + +// DiscoveredSecuritySolutionProperties ... +type DiscoveredSecuritySolutionProperties struct { + // SecurityFamily - The security family of the discovered solution. Possible values include: 'Waf', 'Ngfw', 'SaasWaf', 'Va' + SecurityFamily Family `json:"securityFamily,omitempty"` + // Offer - The security solutions' image offer + Offer *string `json:"offer,omitempty"` + // Publisher - The security solutions' image publisher + Publisher *string `json:"publisher,omitempty"` + // Sku - The security solutions' image sku + Sku *string `json:"sku,omitempty"` +} + +// EffectiveNetworkSecurityGroups describes the Network Security Groups effective on a network interface +type EffectiveNetworkSecurityGroups struct { + // NetworkInterface - The Azure resource ID of the network interface + NetworkInterface *string `json:"networkInterface,omitempty"` + // NetworkSecurityGroups - The Network Security Groups effective on the network interface + NetworkSecurityGroups *[]string `json:"networkSecurityGroups,omitempty"` +} + +// ETag entity tag is used for comparing two or more entities from the same requested resource. +type ETag struct { + // Etag - Entity tag is used for comparing two or more entities from the same requested resource. + Etag *string `json:"etag,omitempty"` +} + +// BasicExternalSecuritySolution represents a security solution external to Azure Security Center which sends +// information to an OMS workspace and whose data is displayed by Azure Security Center. +type BasicExternalSecuritySolution interface { + AsCefExternalSecuritySolution() (*CefExternalSecuritySolution, bool) + AsAtaExternalSecuritySolution() (*AtaExternalSecuritySolution, bool) + AsAadExternalSecuritySolution() (*AadExternalSecuritySolution, bool) + AsExternalSecuritySolution() (*ExternalSecuritySolution, bool) +} + +// ExternalSecuritySolution represents a security solution external to Azure Security Center which sends +// information to an OMS workspace and whose data is displayed by Azure Security Center. +type ExternalSecuritySolution struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + // Kind - Possible values include: 'KindExternalSecuritySolution', 'KindCEF', 'KindATA', 'KindAAD' + Kind KindEnum1 `json:"kind,omitempty"` +} + +func unmarshalBasicExternalSecuritySolution(body []byte) (BasicExternalSecuritySolution, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindCEF): + var cess CefExternalSecuritySolution + err := json.Unmarshal(body, &cess) + return cess, err + case string(KindATA): + var aess AtaExternalSecuritySolution + err := json.Unmarshal(body, &aess) + return aess, err + case string(KindAAD): + var aess AadExternalSecuritySolution + err := json.Unmarshal(body, &aess) + return aess, err + default: + var ess ExternalSecuritySolution + err := json.Unmarshal(body, &ess) + return ess, err + } +} +func unmarshalBasicExternalSecuritySolutionArray(body []byte) ([]BasicExternalSecuritySolution, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + essArray := make([]BasicExternalSecuritySolution, len(rawMessages)) + + for index, rawMessage := range rawMessages { + ess, err := unmarshalBasicExternalSecuritySolution(*rawMessage) + if err != nil { + return nil, err + } + essArray[index] = ess + } + return essArray, nil +} + +// MarshalJSON is the custom marshaler for ExternalSecuritySolution. +func (ess ExternalSecuritySolution) MarshalJSON() ([]byte, error) { + ess.Kind = KindExternalSecuritySolution + objectMap := make(map[string]interface{}) + if ess.Kind != "" { + objectMap["kind"] = ess.Kind + } + return json.Marshal(objectMap) +} + +// AsCefExternalSecuritySolution is the BasicExternalSecuritySolution implementation for ExternalSecuritySolution. +func (ess ExternalSecuritySolution) AsCefExternalSecuritySolution() (*CefExternalSecuritySolution, bool) { + return nil, false +} + +// AsAtaExternalSecuritySolution is the BasicExternalSecuritySolution implementation for ExternalSecuritySolution. +func (ess ExternalSecuritySolution) AsAtaExternalSecuritySolution() (*AtaExternalSecuritySolution, bool) { + return nil, false +} + +// AsAadExternalSecuritySolution is the BasicExternalSecuritySolution implementation for ExternalSecuritySolution. +func (ess ExternalSecuritySolution) AsAadExternalSecuritySolution() (*AadExternalSecuritySolution, bool) { + return nil, false +} + +// AsExternalSecuritySolution is the BasicExternalSecuritySolution implementation for ExternalSecuritySolution. +func (ess ExternalSecuritySolution) AsExternalSecuritySolution() (*ExternalSecuritySolution, bool) { + return &ess, true +} + +// AsBasicExternalSecuritySolution is the BasicExternalSecuritySolution implementation for ExternalSecuritySolution. +func (ess ExternalSecuritySolution) AsBasicExternalSecuritySolution() (BasicExternalSecuritySolution, bool) { + return &ess, true +} + +// ExternalSecuritySolutionKind1 describes an Azure resource with kind +type ExternalSecuritySolutionKind1 struct { + // Kind - The kind of the external solution. Possible values include: 'CEF', 'ATA', 'AAD' + Kind ExternalSecuritySolutionKind `json:"kind,omitempty"` +} + +// ExternalSecuritySolutionList ... +type ExternalSecuritySolutionList struct { + autorest.Response `json:"-"` + Value *[]BasicExternalSecuritySolution `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExternalSecuritySolutionList. +func (essl ExternalSecuritySolutionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if essl.Value != nil { + objectMap["value"] = essl.Value + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExternalSecuritySolutionList struct. +func (essl *ExternalSecuritySolutionList) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "value": + if v != nil { + value, err := unmarshalBasicExternalSecuritySolutionArray(*v) + if err != nil { + return err + } + essl.Value = &value + } + case "nextLink": + if v != nil { + var nextLink string + err = json.Unmarshal(*v, &nextLink) + if err != nil { + return err + } + essl.NextLink = &nextLink + } + } + } + + return nil +} + +// ExternalSecuritySolutionListIterator provides access to a complete listing of ExternalSecuritySolution +// values. +type ExternalSecuritySolutionListIterator struct { + i int + page ExternalSecuritySolutionListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ExternalSecuritySolutionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExternalSecuritySolutionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ExternalSecuritySolutionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ExternalSecuritySolutionListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ExternalSecuritySolutionListIterator) Response() ExternalSecuritySolutionList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ExternalSecuritySolutionListIterator) Value() BasicExternalSecuritySolution { + if !iter.page.NotDone() { + return ExternalSecuritySolution{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ExternalSecuritySolutionListIterator type. +func NewExternalSecuritySolutionListIterator(page ExternalSecuritySolutionListPage) ExternalSecuritySolutionListIterator { + return ExternalSecuritySolutionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (essl ExternalSecuritySolutionList) IsEmpty() bool { + return essl.Value == nil || len(*essl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (essl ExternalSecuritySolutionList) hasNextLink() bool { + return essl.NextLink != nil && len(*essl.NextLink) != 0 +} + +// externalSecuritySolutionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (essl ExternalSecuritySolutionList) externalSecuritySolutionListPreparer(ctx context.Context) (*http.Request, error) { + if !essl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(essl.NextLink))) +} + +// ExternalSecuritySolutionListPage contains a page of BasicExternalSecuritySolution values. +type ExternalSecuritySolutionListPage struct { + fn func(context.Context, ExternalSecuritySolutionList) (ExternalSecuritySolutionList, error) + essl ExternalSecuritySolutionList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ExternalSecuritySolutionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExternalSecuritySolutionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.essl) + if err != nil { + return err + } + page.essl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ExternalSecuritySolutionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ExternalSecuritySolutionListPage) NotDone() bool { + return !page.essl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ExternalSecuritySolutionListPage) Response() ExternalSecuritySolutionList { + return page.essl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ExternalSecuritySolutionListPage) Values() []BasicExternalSecuritySolution { + if page.essl.IsEmpty() { + return nil + } + return *page.essl.Value +} + +// Creates a new instance of the ExternalSecuritySolutionListPage type. +func NewExternalSecuritySolutionListPage(getNextPage func(context.Context, ExternalSecuritySolutionList) (ExternalSecuritySolutionList, error)) ExternalSecuritySolutionListPage { + return ExternalSecuritySolutionListPage{fn: getNextPage} +} + +// ExternalSecuritySolutionModel ... +type ExternalSecuritySolutionModel struct { + autorest.Response `json:"-"` + Value BasicExternalSecuritySolution `json:"value,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for ExternalSecuritySolutionModel struct. +func (essm *ExternalSecuritySolutionModel) UnmarshalJSON(body []byte) error { + ess, err := unmarshalBasicExternalSecuritySolution(body) + if err != nil { + return err + } + essm.Value = ess + + return nil +} + +// ExternalSecuritySolutionProperties the solution properties (correspond to the solution kind) +type ExternalSecuritySolutionProperties struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + DeviceVendor *string `json:"deviceVendor,omitempty"` + DeviceType *string `json:"deviceType,omitempty"` + Workspace *ConnectedWorkspace `json:"workspace,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExternalSecuritySolutionProperties. +func (essp ExternalSecuritySolutionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if essp.DeviceVendor != nil { + objectMap["deviceVendor"] = essp.DeviceVendor + } + if essp.DeviceType != nil { + objectMap["deviceType"] = essp.DeviceType + } + if essp.Workspace != nil { + objectMap["workspace"] = essp.Workspace + } + for k, v := range essp.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExternalSecuritySolutionProperties struct. +func (essp *ExternalSecuritySolutionProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if essp.AdditionalProperties == nil { + essp.AdditionalProperties = make(map[string]interface{}) + } + essp.AdditionalProperties[k] = additionalProperties + } + case "deviceVendor": + if v != nil { + var deviceVendor string + err = json.Unmarshal(*v, &deviceVendor) + if err != nil { + return err + } + essp.DeviceVendor = &deviceVendor + } + case "deviceType": + if v != nil { + var deviceType string + err = json.Unmarshal(*v, &deviceType) + if err != nil { + return err + } + essp.DeviceType = &deviceType + } + case "workspace": + if v != nil { + var workspace ConnectedWorkspace + err = json.Unmarshal(*v, &workspace) + if err != nil { + return err + } + essp.Workspace = &workspace + } + } + } + + return nil +} + +// FailedLocalLoginsNotInAllowedRange number of failed local logins is not in allowed range. +type FailedLocalLoginsNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) MarshalJSON() ([]byte, error) { + fllniar.RuleType = RuleTypeFailedLocalLoginsNotInAllowedRange + objectMap := make(map[string]interface{}) + if fllniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = fllniar.TimeWindowSize + } + if fllniar.MinThreshold != nil { + objectMap["minThreshold"] = fllniar.MinThreshold + } + if fllniar.MaxThreshold != nil { + objectMap["maxThreshold"] = fllniar.MaxThreshold + } + if fllniar.IsEnabled != nil { + objectMap["isEnabled"] = fllniar.IsEnabled + } + if fllniar.RuleType != "" { + objectMap["ruleType"] = fllniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &fllniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &fllniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return &fllniar, true +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for FailedLocalLoginsNotInAllowedRange. +func (fllniar FailedLocalLoginsNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &fllniar, true +} + +// FileUploadsNotInAllowedRange number of file uploads is not in allowed range. +type FileUploadsNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) MarshalJSON() ([]byte, error) { + funiar.RuleType = RuleTypeFileUploadsNotInAllowedRange + objectMap := make(map[string]interface{}) + if funiar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = funiar.TimeWindowSize + } + if funiar.MinThreshold != nil { + objectMap["minThreshold"] = funiar.MinThreshold + } + if funiar.MaxThreshold != nil { + objectMap["maxThreshold"] = funiar.MaxThreshold + } + if funiar.IsEnabled != nil { + objectMap["isEnabled"] = funiar.IsEnabled + } + if funiar.RuleType != "" { + objectMap["ruleType"] = funiar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &funiar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &funiar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return &funiar, true +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for FileUploadsNotInAllowedRange. +func (funiar FileUploadsNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &funiar, true +} + +// GcpCredentialsDetailsProperties GCP cloud account connector based service to service credentials, the +// credentials is composed of organization id and json api key (write only) +type GcpCredentialsDetailsProperties struct { + // OrganizationID - The Organization ID of the GCP cloud account + OrganizationID *string `json:"organizationId,omitempty"` + // Type - Type field of the API key (write only) + Type *string `json:"type,omitempty"` + // ProjectID - Project Id field of the API key (write only) + ProjectID *string `json:"projectId,omitempty"` + // PrivateKeyID - Private key Id field of the API key (write only) + PrivateKeyID *string `json:"privateKeyId,omitempty"` + // PrivateKey - Private key field of the API key (write only) + PrivateKey *string `json:"privateKey,omitempty"` + // ClientEmail - Client email field of the API key (write only) + ClientEmail *string `json:"clientEmail,omitempty"` + // ClientID - Client Id field of the API key (write only) + ClientID *string `json:"clientId,omitempty"` + // AuthURI - Auth Uri field of the API key (write only) + AuthURI *string `json:"authUri,omitempty"` + // TokenURI - Token Uri field of the API key (write only) + TokenURI *string `json:"tokenUri,omitempty"` + // AuthProviderX509CertURL - Auth provider x509 certificate url field of the API key (write only) + AuthProviderX509CertURL *string `json:"authProviderX509CertUrl,omitempty"` + // ClientX509CertURL - Client x509 certificate url field of the API key (write only) + ClientX509CertURL *string `json:"clientX509CertUrl,omitempty"` + // AuthenticationProvisioningState - READ-ONLY; State of the multi-cloud connector. Possible values include: 'Valid', 'Invalid', 'Expired', 'IncorrectPolicy' + AuthenticationProvisioningState AuthenticationProvisioningState `json:"authenticationProvisioningState,omitempty"` + // GrantedPermissions - READ-ONLY; The permissions detected in the cloud account. + GrantedPermissions *[]PermissionProperty `json:"grantedPermissions,omitempty"` + // AuthenticationType - Possible values include: 'AuthenticationTypeAuthenticationDetailsProperties', 'AuthenticationTypeAwsCreds', 'AuthenticationTypeAwsAssumeRole', 'AuthenticationTypeGcpCredentials' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` +} + +// MarshalJSON is the custom marshaler for GcpCredentialsDetailsProperties. +func (gcdp GcpCredentialsDetailsProperties) MarshalJSON() ([]byte, error) { + gcdp.AuthenticationType = AuthenticationTypeGcpCredentials + objectMap := make(map[string]interface{}) + if gcdp.OrganizationID != nil { + objectMap["organizationId"] = gcdp.OrganizationID + } + if gcdp.Type != nil { + objectMap["type"] = gcdp.Type + } + if gcdp.ProjectID != nil { + objectMap["projectId"] = gcdp.ProjectID + } + if gcdp.PrivateKeyID != nil { + objectMap["privateKeyId"] = gcdp.PrivateKeyID + } + if gcdp.PrivateKey != nil { + objectMap["privateKey"] = gcdp.PrivateKey + } + if gcdp.ClientEmail != nil { + objectMap["clientEmail"] = gcdp.ClientEmail + } + if gcdp.ClientID != nil { + objectMap["clientId"] = gcdp.ClientID + } + if gcdp.AuthURI != nil { + objectMap["authUri"] = gcdp.AuthURI + } + if gcdp.TokenURI != nil { + objectMap["tokenUri"] = gcdp.TokenURI + } + if gcdp.AuthProviderX509CertURL != nil { + objectMap["authProviderX509CertUrl"] = gcdp.AuthProviderX509CertURL + } + if gcdp.ClientX509CertURL != nil { + objectMap["clientX509CertUrl"] = gcdp.ClientX509CertURL + } + if gcdp.AuthenticationType != "" { + objectMap["authenticationType"] = gcdp.AuthenticationType + } + return json.Marshal(objectMap) +} + +// AsAwsCredsAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for GcpCredentialsDetailsProperties. +func (gcdp GcpCredentialsDetailsProperties) AsAwsCredsAuthenticationDetailsProperties() (*AwsCredsAuthenticationDetailsProperties, bool) { + return nil, false +} + +// AsAwAssumeRoleAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for GcpCredentialsDetailsProperties. +func (gcdp GcpCredentialsDetailsProperties) AsAwAssumeRoleAuthenticationDetailsProperties() (*AwAssumeRoleAuthenticationDetailsProperties, bool) { + return nil, false +} + +// AsGcpCredentialsDetailsProperties is the BasicAuthenticationDetailsProperties implementation for GcpCredentialsDetailsProperties. +func (gcdp GcpCredentialsDetailsProperties) AsGcpCredentialsDetailsProperties() (*GcpCredentialsDetailsProperties, bool) { + return &gcdp, true +} + +// AsAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for GcpCredentialsDetailsProperties. +func (gcdp GcpCredentialsDetailsProperties) AsAuthenticationDetailsProperties() (*AuthenticationDetailsProperties, bool) { + return nil, false +} + +// AsBasicAuthenticationDetailsProperties is the BasicAuthenticationDetailsProperties implementation for GcpCredentialsDetailsProperties. +func (gcdp GcpCredentialsDetailsProperties) AsBasicAuthenticationDetailsProperties() (BasicAuthenticationDetailsProperties, bool) { + return &gcdp, true +} + +// HTTPC2DMessagesNotInAllowedRange number of cloud to device messages (HTTP protocol) is not in allowed range. +type HTTPC2DMessagesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { + hcmniar.RuleType = RuleTypeHTTPC2DMessagesNotInAllowedRange + objectMap := make(map[string]interface{}) + if hcmniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = hcmniar.TimeWindowSize + } + if hcmniar.MinThreshold != nil { + objectMap["minThreshold"] = hcmniar.MinThreshold + } + if hcmniar.MaxThreshold != nil { + objectMap["maxThreshold"] = hcmniar.MaxThreshold + } + if hcmniar.IsEnabled != nil { + objectMap["isEnabled"] = hcmniar.IsEnabled + } + if hcmniar.RuleType != "" { + objectMap["ruleType"] = hcmniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &hcmniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &hcmniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return &hcmniar, true +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DMessagesNotInAllowedRange. +func (hcmniar HTTPC2DMessagesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &hcmniar, true +} + +// HTTPC2DRejectedMessagesNotInAllowedRange number of rejected cloud to device messages (HTTP protocol) is not +// in allowed range. +type HTTPC2DRejectedMessagesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { + hcrmniar.RuleType = RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange + objectMap := make(map[string]interface{}) + if hcrmniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = hcrmniar.TimeWindowSize + } + if hcrmniar.MinThreshold != nil { + objectMap["minThreshold"] = hcrmniar.MinThreshold + } + if hcrmniar.MaxThreshold != nil { + objectMap["maxThreshold"] = hcrmniar.MaxThreshold + } + if hcrmniar.IsEnabled != nil { + objectMap["isEnabled"] = hcrmniar.IsEnabled + } + if hcrmniar.RuleType != "" { + objectMap["ruleType"] = hcrmniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &hcrmniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &hcrmniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return &hcrmniar, true +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for HTTPC2DRejectedMessagesNotInAllowedRange. +func (hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &hcrmniar, true +} + +// HTTPD2CMessagesNotInAllowedRange number of device to cloud messages (HTTP protocol) is not in allowed range. +type HTTPD2CMessagesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { + hdmniar.RuleType = RuleTypeHTTPD2CMessagesNotInAllowedRange + objectMap := make(map[string]interface{}) + if hdmniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = hdmniar.TimeWindowSize + } + if hdmniar.MinThreshold != nil { + objectMap["minThreshold"] = hdmniar.MinThreshold + } + if hdmniar.MaxThreshold != nil { + objectMap["maxThreshold"] = hdmniar.MaxThreshold + } + if hdmniar.IsEnabled != nil { + objectMap["isEnabled"] = hdmniar.IsEnabled + } + if hdmniar.RuleType != "" { + objectMap["ruleType"] = hdmniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &hdmniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &hdmniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return &hdmniar, true +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for HTTPD2CMessagesNotInAllowedRange. +func (hdmniar HTTPD2CMessagesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &hdmniar, true +} + +// HybridComputeSettingsProperties settings for hybrid compute management +type HybridComputeSettingsProperties struct { + // HybridComputeProvisioningState - READ-ONLY; State of the service principal and its secret. Possible values include: 'HybridComputeProvisioningStateValid', 'HybridComputeProvisioningStateInvalid', 'HybridComputeProvisioningStateExpired' + HybridComputeProvisioningState HybridComputeProvisioningState `json:"hybridComputeProvisioningState,omitempty"` + // AutoProvision - Whether or not to automatically install Azure Arc (hybrid compute) agents on machines. Possible values include: 'AutoProvisionOn', 'AutoProvisionOff' + AutoProvision AutoProvision `json:"autoProvision,omitempty"` + // ResourceGroupName - The name of the resource group where Arc (Hybrid Compute) connectors are connected. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // Region - The location where the meta data of machines will be stored + Region *string `json:"region,omitempty"` + // ProxyServer - For a non-Azure machine that is not connected directly to the internet, specify a proxy server that the non-Azure machine can use. + ProxyServer *ProxyServerProperties `json:"proxyServer,omitempty"` + // ServicePrincipal - An object to access resources that are secured by an Azure AD tenant. + ServicePrincipal *ServicePrincipalProperties `json:"servicePrincipal,omitempty"` +} + +// MarshalJSON is the custom marshaler for HybridComputeSettingsProperties. +func (hcsp HybridComputeSettingsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if hcsp.AutoProvision != "" { + objectMap["autoProvision"] = hcsp.AutoProvision + } + if hcsp.ResourceGroupName != nil { + objectMap["resourceGroupName"] = hcsp.ResourceGroupName + } + if hcsp.Region != nil { + objectMap["region"] = hcsp.Region + } + if hcsp.ProxyServer != nil { + objectMap["proxyServer"] = hcsp.ProxyServer + } + if hcsp.ServicePrincipal != nil { + objectMap["servicePrincipal"] = hcsp.ServicePrincipal + } + return json.Marshal(objectMap) +} + +// InformationProtectionKeyword the information type keyword. +type InformationProtectionKeyword struct { + // Pattern - The keyword pattern. + Pattern *string `json:"pattern,omitempty"` + // Custom - Indicates whether the keyword is custom or not. + Custom *bool `json:"custom,omitempty"` + // CanBeNumeric - Indicates whether the keyword can be applied on numeric types or not. + CanBeNumeric *bool `json:"canBeNumeric,omitempty"` + // Excluded - Indicates whether the keyword is excluded or not. + Excluded *bool `json:"excluded,omitempty"` +} + +// InformationProtectionPolicy information protection policy. +type InformationProtectionPolicy struct { + autorest.Response `json:"-"` + // InformationProtectionPolicyProperties - Information protection policy data + *InformationProtectionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for InformationProtectionPolicy. +func (ipp InformationProtectionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipp.InformationProtectionPolicyProperties != nil { + objectMap["properties"] = ipp.InformationProtectionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for InformationProtectionPolicy struct. +func (ipp *InformationProtectionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var informationProtectionPolicyProperties InformationProtectionPolicyProperties + err = json.Unmarshal(*v, &informationProtectionPolicyProperties) + if err != nil { + return err + } + ipp.InformationProtectionPolicyProperties = &informationProtectionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ipp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ipp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ipp.Type = &typeVar + } + } + } + + return nil +} + +// InformationProtectionPolicyList information protection policies response. +type InformationProtectionPolicyList struct { + autorest.Response `json:"-"` + // Value - List of information protection policies. + Value *[]InformationProtectionPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for InformationProtectionPolicyList. +func (ippl InformationProtectionPolicyList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ippl.Value != nil { + objectMap["value"] = ippl.Value + } + return json.Marshal(objectMap) +} + +// InformationProtectionPolicyListIterator provides access to a complete listing of InformationProtectionPolicy +// values. +type InformationProtectionPolicyListIterator struct { + i int + page InformationProtectionPolicyListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *InformationProtectionPolicyListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InformationProtectionPolicyListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *InformationProtectionPolicyListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter InformationProtectionPolicyListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter InformationProtectionPolicyListIterator) Response() InformationProtectionPolicyList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter InformationProtectionPolicyListIterator) Value() InformationProtectionPolicy { + if !iter.page.NotDone() { + return InformationProtectionPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the InformationProtectionPolicyListIterator type. +func NewInformationProtectionPolicyListIterator(page InformationProtectionPolicyListPage) InformationProtectionPolicyListIterator { + return InformationProtectionPolicyListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ippl InformationProtectionPolicyList) IsEmpty() bool { + return ippl.Value == nil || len(*ippl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ippl InformationProtectionPolicyList) hasNextLink() bool { + return ippl.NextLink != nil && len(*ippl.NextLink) != 0 +} + +// informationProtectionPolicyListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ippl InformationProtectionPolicyList) informationProtectionPolicyListPreparer(ctx context.Context) (*http.Request, error) { + if !ippl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ippl.NextLink))) +} + +// InformationProtectionPolicyListPage contains a page of InformationProtectionPolicy values. +type InformationProtectionPolicyListPage struct { + fn func(context.Context, InformationProtectionPolicyList) (InformationProtectionPolicyList, error) + ippl InformationProtectionPolicyList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *InformationProtectionPolicyListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InformationProtectionPolicyListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ippl) + if err != nil { + return err + } + page.ippl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *InformationProtectionPolicyListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page InformationProtectionPolicyListPage) NotDone() bool { + return !page.ippl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page InformationProtectionPolicyListPage) Response() InformationProtectionPolicyList { + return page.ippl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page InformationProtectionPolicyListPage) Values() []InformationProtectionPolicy { + if page.ippl.IsEmpty() { + return nil + } + return *page.ippl.Value +} + +// Creates a new instance of the InformationProtectionPolicyListPage type. +func NewInformationProtectionPolicyListPage(getNextPage func(context.Context, InformationProtectionPolicyList) (InformationProtectionPolicyList, error)) InformationProtectionPolicyListPage { + return InformationProtectionPolicyListPage{fn: getNextPage} +} + +// InformationProtectionPolicyProperties describes properties of an information protection policy. +type InformationProtectionPolicyProperties struct { + // LastModifiedUtc - READ-ONLY; Describes the last UTC time the policy was modified. + LastModifiedUtc *date.Time `json:"lastModifiedUtc,omitempty"` + // Version - READ-ONLY; Describes the version of the policy. + Version *string `json:"version,omitempty"` + // Labels - Dictionary of sensitivity labels. + Labels map[string]*SensitivityLabel `json:"labels"` + // InformationTypes - The sensitivity information types. + InformationTypes map[string]*InformationType `json:"informationTypes"` +} + +// MarshalJSON is the custom marshaler for InformationProtectionPolicyProperties. +func (ippp InformationProtectionPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ippp.Labels != nil { + objectMap["labels"] = ippp.Labels + } + if ippp.InformationTypes != nil { + objectMap["informationTypes"] = ippp.InformationTypes + } + return json.Marshal(objectMap) +} + +// InformationType the information type. +type InformationType struct { + // DisplayName - The name of the information type. + DisplayName *string `json:"displayName,omitempty"` + // Description - The description of the information type. + Description *string `json:"description,omitempty"` + // Order - The order of the information type. + Order *int32 `json:"order,omitempty"` + // RecommendedLabelID - The recommended label id to be associated with this information type. + RecommendedLabelID *uuid.UUID `json:"recommendedLabelId,omitempty"` + // Enabled - Indicates whether the information type is enabled or not. + Enabled *bool `json:"enabled,omitempty"` + // Custom - Indicates whether the information type is custom or not. + Custom *bool `json:"custom,omitempty"` + // Keywords - The information type keywords. + Keywords *[]InformationProtectionKeyword `json:"keywords,omitempty"` +} + +// IotAlert ioT alert +type IotAlert struct { + autorest.Response `json:"-"` + // IotAlertProperties - Alert properties + *IotAlertProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotAlert. +func (ia IotAlert) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ia.IotAlertProperties != nil { + objectMap["properties"] = ia.IotAlertProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IotAlert struct. +func (ia *IotAlert) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var iotAlertProperties IotAlertProperties + err = json.Unmarshal(*v, &iotAlertProperties) + if err != nil { + return err + } + ia.IotAlertProperties = &iotAlertProperties + } + } + } + + return nil +} + +// IotAlertList list of IoT alerts +type IotAlertList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List data + Value *[]IotAlert `json:"value,omitempty"` + // NextLink - READ-ONLY; When available, follow the URI to get the next page of data + NextLink *string `json:"nextLink,omitempty"` + // TotalCount - READ-ONLY; Total count of alerts that conforms with the given filter options (not affected by page size) + TotalCount *int32 `json:"totalCount,omitempty"` +} + +// IotAlertListIterator provides access to a complete listing of IotAlert values. +type IotAlertListIterator struct { + i int + page IotAlertListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IotAlertListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotAlertListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IotAlertListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IotAlertListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IotAlertListIterator) Response() IotAlertList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IotAlertListIterator) Value() IotAlert { + if !iter.page.NotDone() { + return IotAlert{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IotAlertListIterator type. +func NewIotAlertListIterator(page IotAlertListPage) IotAlertListIterator { + return IotAlertListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ial IotAlertList) IsEmpty() bool { + return ial.Value == nil || len(*ial.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ial IotAlertList) hasNextLink() bool { + return ial.NextLink != nil && len(*ial.NextLink) != 0 +} + +// iotAlertListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ial IotAlertList) iotAlertListPreparer(ctx context.Context) (*http.Request, error) { + if !ial.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ial.NextLink))) +} + +// IotAlertListPage contains a page of IotAlert values. +type IotAlertListPage struct { + fn func(context.Context, IotAlertList) (IotAlertList, error) + ial IotAlertList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IotAlertListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotAlertListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ial) + if err != nil { + return err + } + page.ial = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IotAlertListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IotAlertListPage) NotDone() bool { + return !page.ial.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IotAlertListPage) Response() IotAlertList { + return page.ial +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IotAlertListPage) Values() []IotAlert { + if page.ial.IsEmpty() { + return nil + } + return *page.ial.Value +} + +// Creates a new instance of the IotAlertListPage type. +func NewIotAlertListPage(getNextPage func(context.Context, IotAlertList) (IotAlertList, error)) IotAlertListPage { + return IotAlertListPage{fn: getNextPage} +} + +// IotAlertProperties ioT alert properties +type IotAlertProperties struct { + // SystemAlertID - READ-ONLY; Holds the product canonical identifier of the alert within the scope of a product + SystemAlertID *string `json:"systemAlertId,omitempty"` + // CompromisedEntity - READ-ONLY; Display name of the main entity being reported on + CompromisedEntity *string `json:"compromisedEntity,omitempty"` + // AlertType - READ-ONLY; The type name of the alert + AlertType *string `json:"alertType,omitempty"` + // StartTimeUtc - READ-ONLY; The impact start time of the alert (the time of the first event or activity included in the alert) + StartTimeUtc *string `json:"startTimeUtc,omitempty"` + // EndTimeUtc - READ-ONLY; The impact end time of the alert (the time of the last event or activity included in the alert) + EndTimeUtc *string `json:"endTimeUtc,omitempty"` + // Entities - A list of entities related to the alert + Entities *[]interface{} `json:"entities,omitempty"` + // ExtendedProperties - A bag of fields which extends the alert information + ExtendedProperties interface{} `json:"extendedProperties,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotAlertProperties. +func (iap IotAlertProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if iap.Entities != nil { + objectMap["entities"] = iap.Entities + } + if iap.ExtendedProperties != nil { + objectMap["extendedProperties"] = iap.ExtendedProperties + } + return json.Marshal(objectMap) +} + +// IotAlertType ioT alert type. +type IotAlertType struct { + autorest.Response `json:"-"` + // IotAlertTypeProperties - Alert type properties + *IotAlertTypeProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotAlertType. +func (iat IotAlertType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if iat.IotAlertTypeProperties != nil { + objectMap["properties"] = iat.IotAlertTypeProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IotAlertType struct. +func (iat *IotAlertType) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var iotAlertTypeProperties IotAlertTypeProperties + err = json.Unmarshal(*v, &iotAlertTypeProperties) + if err != nil { + return err + } + iat.IotAlertTypeProperties = &iotAlertTypeProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + iat.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + iat.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + iat.Type = &typeVar + } + } + } + + return nil +} + +// IotAlertTypeList list of alert types +type IotAlertTypeList struct { + autorest.Response `json:"-"` + // Value - List data + Value *[]IotAlertType `json:"value,omitempty"` +} + +// IotAlertTypeProperties ioT alert type information. +type IotAlertTypeProperties struct { + // AlertDisplayName - READ-ONLY; The display name of the alert + AlertDisplayName *string `json:"alertDisplayName,omitempty"` + // Severity - READ-ONLY; The severity of the alert. Possible values include: 'Informational', 'Low', 'Medium', 'High' + Severity AlertSeverity `json:"severity,omitempty"` + // Description - READ-ONLY; Description of the suspected vulnerability and meaning. + Description *string `json:"description,omitempty"` + // ProviderName - READ-ONLY; The name of the alert provider or internal partner + ProviderName *string `json:"providerName,omitempty"` + // ProductName - READ-ONLY; The name of the product which published this alert + ProductName *string `json:"productName,omitempty"` + // ProductComponentName - READ-ONLY; The name of a component inside the product which generated the alert + ProductComponentName *string `json:"productComponentName,omitempty"` + // VendorName - READ-ONLY; The name of the vendor that raise the alert + VendorName *string `json:"vendorName,omitempty"` + // Intent - READ-ONLY; Kill chain related intent behind the alert. Could contain multiple enum values (separated by commas). Possible values include: 'Unknown', 'PreAttack', 'InitialAccess', 'Persistence', 'PrivilegeEscalation', 'DefenseEvasion', 'CredentialAccess', 'Discovery', 'LateralMovement', 'Execution', 'Collection', 'Exfiltration', 'CommandAndControl', 'Impact', 'Probing', 'Exploitation' + Intent AlertIntent `json:"intent,omitempty"` + // RemediationSteps - READ-ONLY; Manual action items to take to remediate the alert + RemediationSteps *[]string `json:"remediationSteps,omitempty"` +} + +// IotRecommendation ioT recommendation +type IotRecommendation struct { + autorest.Response `json:"-"` + // IotRecommendationProperties - Recommendation properties + *IotRecommendationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotRecommendation. +func (ir IotRecommendation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ir.IotRecommendationProperties != nil { + objectMap["properties"] = ir.IotRecommendationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IotRecommendation struct. +func (ir *IotRecommendation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var iotRecommendationProperties IotRecommendationProperties + err = json.Unmarshal(*v, &iotRecommendationProperties) + if err != nil { + return err + } + ir.IotRecommendationProperties = &iotRecommendationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ir.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ir.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ir.Type = &typeVar + } + } + } + + return nil +} + +// IotRecommendationList list of IoT recommendations +type IotRecommendationList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List data + Value *[]IotRecommendation `json:"value,omitempty"` + // NextLink - READ-ONLY; When available, follow the URI to get the next page of data + NextLink *string `json:"nextLink,omitempty"` + // TotalCount - READ-ONLY; Total count of recommendations that conforms with the given filter options (not affected by page size) + TotalCount *int32 `json:"totalCount,omitempty"` +} + +// IotRecommendationListIterator provides access to a complete listing of IotRecommendation values. +type IotRecommendationListIterator struct { + i int + page IotRecommendationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IotRecommendationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotRecommendationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IotRecommendationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IotRecommendationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IotRecommendationListIterator) Response() IotRecommendationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IotRecommendationListIterator) Value() IotRecommendation { + if !iter.page.NotDone() { + return IotRecommendation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IotRecommendationListIterator type. +func NewIotRecommendationListIterator(page IotRecommendationListPage) IotRecommendationListIterator { + return IotRecommendationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (irl IotRecommendationList) IsEmpty() bool { + return irl.Value == nil || len(*irl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (irl IotRecommendationList) hasNextLink() bool { + return irl.NextLink != nil && len(*irl.NextLink) != 0 +} + +// iotRecommendationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (irl IotRecommendationList) iotRecommendationListPreparer(ctx context.Context) (*http.Request, error) { + if !irl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(irl.NextLink))) +} + +// IotRecommendationListPage contains a page of IotRecommendation values. +type IotRecommendationListPage struct { + fn func(context.Context, IotRecommendationList) (IotRecommendationList, error) + irl IotRecommendationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IotRecommendationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotRecommendationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.irl) + if err != nil { + return err + } + page.irl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IotRecommendationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IotRecommendationListPage) NotDone() bool { + return !page.irl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IotRecommendationListPage) Response() IotRecommendationList { + return page.irl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IotRecommendationListPage) Values() []IotRecommendation { + if page.irl.IsEmpty() { + return nil + } + return *page.irl.Value +} + +// Creates a new instance of the IotRecommendationListPage type. +func NewIotRecommendationListPage(getNextPage func(context.Context, IotRecommendationList) (IotRecommendationList, error)) IotRecommendationListPage { + return IotRecommendationListPage{fn: getNextPage} +} + +// IotRecommendationProperties ioT recommendation properties +type IotRecommendationProperties struct { + // DeviceID - READ-ONLY; Identifier of the device being reported on + DeviceID *string `json:"deviceId,omitempty"` + // RecommendationType - READ-ONLY; The type name of the recommendation + RecommendationType *string `json:"recommendationType,omitempty"` + // DiscoveredTimeUtc - READ-ONLY; The discovery time of the recommendation + DiscoveredTimeUtc *string `json:"discoveredTimeUtc,omitempty"` + // RecommendationAdditionalData - A bag of fields which extends the recommendation information + RecommendationAdditionalData interface{} `json:"recommendationAdditionalData,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotRecommendationProperties. +func (irp IotRecommendationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if irp.RecommendationAdditionalData != nil { + objectMap["recommendationAdditionalData"] = irp.RecommendationAdditionalData + } + return json.Marshal(objectMap) +} + +// IotRecommendationType ioT recommendation type. +type IotRecommendationType struct { + autorest.Response `json:"-"` + // IotRecommendationTypeProperties - Recommendation type properties + *IotRecommendationTypeProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotRecommendationType. +func (irt IotRecommendationType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if irt.IotRecommendationTypeProperties != nil { + objectMap["properties"] = irt.IotRecommendationTypeProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IotRecommendationType struct. +func (irt *IotRecommendationType) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var iotRecommendationTypeProperties IotRecommendationTypeProperties + err = json.Unmarshal(*v, &iotRecommendationTypeProperties) + if err != nil { + return err + } + irt.IotRecommendationTypeProperties = &iotRecommendationTypeProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + irt.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + irt.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + irt.Type = &typeVar + } + } + } + + return nil +} + +// IotRecommendationTypeList list of recommendation types +type IotRecommendationTypeList struct { + autorest.Response `json:"-"` + // Value - List data + Value *[]IotRecommendationType `json:"value,omitempty"` +} + +// IotRecommendationTypeProperties ioT recommendation type information. +type IotRecommendationTypeProperties struct { + // RecommendationDisplayName - READ-ONLY; The display name of the recommendation + RecommendationDisplayName *string `json:"recommendationDisplayName,omitempty"` + // Severity - READ-ONLY; The severity of the recommendation. Possible values include: 'RecommendationSeverityUnknown', 'RecommendationSeverityNotApplicable', 'RecommendationSeverityHealthy', 'RecommendationSeverityOffByPolicy', 'RecommendationSeverityLow', 'RecommendationSeverityMedium', 'RecommendationSeverityHigh' + Severity RecommendationSeverity `json:"severity,omitempty"` + // Description - READ-ONLY; Description of the suspected vulnerability and meaning. + Description *string `json:"description,omitempty"` + // ProductName - READ-ONLY; The name of the product which published this recommendation + ProductName *string `json:"productName,omitempty"` + // ProductComponentName - READ-ONLY; The name of a component inside the product which generated the recommendation + ProductComponentName *string `json:"productComponentName,omitempty"` + // VendorName - READ-ONLY; The name of the vendor that raised the recommendation + VendorName *string `json:"vendorName,omitempty"` + // Control - READ-ONLY; The name of the recommendation's control category + Control *string `json:"control,omitempty"` + // RemediationSteps - READ-ONLY; Manual action items to take to resolve the recommendation + RemediationSteps *[]string `json:"remediationSteps,omitempty"` + // DataSource - READ-ONLY; The alert's data source + DataSource *string `json:"dataSource,omitempty"` +} + +// IoTSecurityAggregatedAlert security Solution Aggregated Alert information +type IoTSecurityAggregatedAlert struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // IoTSecurityAggregatedAlertProperties - IoT Security solution aggregated alert details. + *IoTSecurityAggregatedAlertProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecurityAggregatedAlert. +func (itsaa IoTSecurityAggregatedAlert) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itsaa.Tags != nil { + objectMap["tags"] = itsaa.Tags + } + if itsaa.IoTSecurityAggregatedAlertProperties != nil { + objectMap["properties"] = itsaa.IoTSecurityAggregatedAlertProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IoTSecurityAggregatedAlert struct. +func (itsaa *IoTSecurityAggregatedAlert) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + itsaa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + itsaa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + itsaa.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + itsaa.Tags = tags + } + case "properties": + if v != nil { + var ioTSecurityAggregatedAlertProperties IoTSecurityAggregatedAlertProperties + err = json.Unmarshal(*v, &ioTSecurityAggregatedAlertProperties) + if err != nil { + return err + } + itsaa.IoTSecurityAggregatedAlertProperties = &ioTSecurityAggregatedAlertProperties + } + } + } + + return nil +} + +// IoTSecurityAggregatedAlertList list of IoT Security solution aggregated alert data. +type IoTSecurityAggregatedAlertList struct { + autorest.Response `json:"-"` + // Value - List of aggregated alerts data. + Value *[]IoTSecurityAggregatedAlert `json:"value,omitempty"` + // NextLink - READ-ONLY; When there is too much alert data for one page, use this URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecurityAggregatedAlertList. +func (itsaal IoTSecurityAggregatedAlertList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itsaal.Value != nil { + objectMap["value"] = itsaal.Value + } + return json.Marshal(objectMap) +} + +// IoTSecurityAggregatedAlertListIterator provides access to a complete listing of IoTSecurityAggregatedAlert +// values. +type IoTSecurityAggregatedAlertListIterator struct { + i int + page IoTSecurityAggregatedAlertListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IoTSecurityAggregatedAlertListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecurityAggregatedAlertListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IoTSecurityAggregatedAlertListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IoTSecurityAggregatedAlertListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IoTSecurityAggregatedAlertListIterator) Response() IoTSecurityAggregatedAlertList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IoTSecurityAggregatedAlertListIterator) Value() IoTSecurityAggregatedAlert { + if !iter.page.NotDone() { + return IoTSecurityAggregatedAlert{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IoTSecurityAggregatedAlertListIterator type. +func NewIoTSecurityAggregatedAlertListIterator(page IoTSecurityAggregatedAlertListPage) IoTSecurityAggregatedAlertListIterator { + return IoTSecurityAggregatedAlertListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (itsaal IoTSecurityAggregatedAlertList) IsEmpty() bool { + return itsaal.Value == nil || len(*itsaal.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (itsaal IoTSecurityAggregatedAlertList) hasNextLink() bool { + return itsaal.NextLink != nil && len(*itsaal.NextLink) != 0 +} + +// ioTSecurityAggregatedAlertListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (itsaal IoTSecurityAggregatedAlertList) ioTSecurityAggregatedAlertListPreparer(ctx context.Context) (*http.Request, error) { + if !itsaal.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(itsaal.NextLink))) +} + +// IoTSecurityAggregatedAlertListPage contains a page of IoTSecurityAggregatedAlert values. +type IoTSecurityAggregatedAlertListPage struct { + fn func(context.Context, IoTSecurityAggregatedAlertList) (IoTSecurityAggregatedAlertList, error) + itsaal IoTSecurityAggregatedAlertList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IoTSecurityAggregatedAlertListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecurityAggregatedAlertListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.itsaal) + if err != nil { + return err + } + page.itsaal = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IoTSecurityAggregatedAlertListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IoTSecurityAggregatedAlertListPage) NotDone() bool { + return !page.itsaal.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IoTSecurityAggregatedAlertListPage) Response() IoTSecurityAggregatedAlertList { + return page.itsaal +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IoTSecurityAggregatedAlertListPage) Values() []IoTSecurityAggregatedAlert { + if page.itsaal.IsEmpty() { + return nil + } + return *page.itsaal.Value +} + +// Creates a new instance of the IoTSecurityAggregatedAlertListPage type. +func NewIoTSecurityAggregatedAlertListPage(getNextPage func(context.Context, IoTSecurityAggregatedAlertList) (IoTSecurityAggregatedAlertList, error)) IoTSecurityAggregatedAlertListPage { + return IoTSecurityAggregatedAlertListPage{fn: getNextPage} +} + +// IoTSecurityAggregatedAlertProperties ioT Security solution aggregated alert details. +type IoTSecurityAggregatedAlertProperties struct { + // AlertType - READ-ONLY; Name of the alert type. + AlertType *string `json:"alertType,omitempty"` + // AlertDisplayName - READ-ONLY; Display name of the alert type. + AlertDisplayName *string `json:"alertDisplayName,omitempty"` + // AggregatedDateUtc - READ-ONLY; Date of detection. + AggregatedDateUtc *date.Date `json:"aggregatedDateUtc,omitempty"` + // VendorName - READ-ONLY; Name of the organization that raised the alert. + VendorName *string `json:"vendorName,omitempty"` + // ReportedSeverity - READ-ONLY; Assessed alert severity. Possible values include: 'ReportedSeverityInformational', 'ReportedSeverityLow', 'ReportedSeverityMedium', 'ReportedSeverityHigh' + ReportedSeverity ReportedSeverity `json:"reportedSeverity,omitempty"` + // RemediationSteps - READ-ONLY; Recommended steps for remediation. + RemediationSteps *string `json:"remediationSteps,omitempty"` + // Description - READ-ONLY; Description of the suspected vulnerability and meaning. + Description *string `json:"description,omitempty"` + // Count - READ-ONLY; Number of alerts occurrences within the aggregated time window. + Count *int32 `json:"count,omitempty"` + // EffectedResourceType - READ-ONLY; Azure resource ID of the resource that received the alerts. + EffectedResourceType *string `json:"effectedResourceType,omitempty"` + // SystemSource - READ-ONLY; The type of the alerted resource (Azure, Non-Azure). + SystemSource *string `json:"systemSource,omitempty"` + // ActionTaken - READ-ONLY; IoT Security solution alert response. + ActionTaken *string `json:"actionTaken,omitempty"` + // LogAnalyticsQuery - READ-ONLY; Log analytics query for getting the list of affected devices/alerts. + LogAnalyticsQuery *string `json:"logAnalyticsQuery,omitempty"` + // TopDevicesList - READ-ONLY; 10 devices with the highest number of occurrences of this alert type, on this day. + TopDevicesList *[]IoTSecurityAggregatedAlertPropertiesTopDevicesListItem `json:"topDevicesList,omitempty"` +} + +// IoTSecurityAggregatedAlertPropertiesTopDevicesListItem ... +type IoTSecurityAggregatedAlertPropertiesTopDevicesListItem struct { + // DeviceID - READ-ONLY; Name of the device. + DeviceID *string `json:"deviceId,omitempty"` + // AlertsCount - READ-ONLY; Number of alerts raised for this device. + AlertsCount *int32 `json:"alertsCount,omitempty"` + // LastOccurrence - READ-ONLY; Most recent time this alert was raised for this device, on this day. + LastOccurrence *string `json:"lastOccurrence,omitempty"` +} + +// IoTSecurityAggregatedRecommendation ioT Security solution recommendation information. +type IoTSecurityAggregatedRecommendation struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // IoTSecurityAggregatedRecommendationProperties - Security Solution data + *IoTSecurityAggregatedRecommendationProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecurityAggregatedRecommendation. +func (itsar IoTSecurityAggregatedRecommendation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itsar.Tags != nil { + objectMap["tags"] = itsar.Tags + } + if itsar.IoTSecurityAggregatedRecommendationProperties != nil { + objectMap["properties"] = itsar.IoTSecurityAggregatedRecommendationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IoTSecurityAggregatedRecommendation struct. +func (itsar *IoTSecurityAggregatedRecommendation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + itsar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + itsar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + itsar.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + itsar.Tags = tags + } + case "properties": + if v != nil { + var ioTSecurityAggregatedRecommendationProperties IoTSecurityAggregatedRecommendationProperties + err = json.Unmarshal(*v, &ioTSecurityAggregatedRecommendationProperties) + if err != nil { + return err + } + itsar.IoTSecurityAggregatedRecommendationProperties = &ioTSecurityAggregatedRecommendationProperties + } + } + } + + return nil +} + +// IoTSecurityAggregatedRecommendationList list of IoT Security solution aggregated recommendations. +type IoTSecurityAggregatedRecommendationList struct { + autorest.Response `json:"-"` + // Value - List of aggregated recommendations data. + Value *[]IoTSecurityAggregatedRecommendation `json:"value,omitempty"` + // NextLink - READ-ONLY; When there is too much alert data for one page, use this URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecurityAggregatedRecommendationList. +func (itsarl IoTSecurityAggregatedRecommendationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itsarl.Value != nil { + objectMap["value"] = itsarl.Value + } + return json.Marshal(objectMap) +} + +// IoTSecurityAggregatedRecommendationListIterator provides access to a complete listing of +// IoTSecurityAggregatedRecommendation values. +type IoTSecurityAggregatedRecommendationListIterator struct { + i int + page IoTSecurityAggregatedRecommendationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IoTSecurityAggregatedRecommendationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecurityAggregatedRecommendationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IoTSecurityAggregatedRecommendationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IoTSecurityAggregatedRecommendationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IoTSecurityAggregatedRecommendationListIterator) Response() IoTSecurityAggregatedRecommendationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IoTSecurityAggregatedRecommendationListIterator) Value() IoTSecurityAggregatedRecommendation { + if !iter.page.NotDone() { + return IoTSecurityAggregatedRecommendation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IoTSecurityAggregatedRecommendationListIterator type. +func NewIoTSecurityAggregatedRecommendationListIterator(page IoTSecurityAggregatedRecommendationListPage) IoTSecurityAggregatedRecommendationListIterator { + return IoTSecurityAggregatedRecommendationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (itsarl IoTSecurityAggregatedRecommendationList) IsEmpty() bool { + return itsarl.Value == nil || len(*itsarl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (itsarl IoTSecurityAggregatedRecommendationList) hasNextLink() bool { + return itsarl.NextLink != nil && len(*itsarl.NextLink) != 0 +} + +// ioTSecurityAggregatedRecommendationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (itsarl IoTSecurityAggregatedRecommendationList) ioTSecurityAggregatedRecommendationListPreparer(ctx context.Context) (*http.Request, error) { + if !itsarl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(itsarl.NextLink))) +} + +// IoTSecurityAggregatedRecommendationListPage contains a page of IoTSecurityAggregatedRecommendation values. +type IoTSecurityAggregatedRecommendationListPage struct { + fn func(context.Context, IoTSecurityAggregatedRecommendationList) (IoTSecurityAggregatedRecommendationList, error) + itsarl IoTSecurityAggregatedRecommendationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IoTSecurityAggregatedRecommendationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecurityAggregatedRecommendationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.itsarl) + if err != nil { + return err + } + page.itsarl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IoTSecurityAggregatedRecommendationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IoTSecurityAggregatedRecommendationListPage) NotDone() bool { + return !page.itsarl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IoTSecurityAggregatedRecommendationListPage) Response() IoTSecurityAggregatedRecommendationList { + return page.itsarl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IoTSecurityAggregatedRecommendationListPage) Values() []IoTSecurityAggregatedRecommendation { + if page.itsarl.IsEmpty() { + return nil + } + return *page.itsarl.Value +} + +// Creates a new instance of the IoTSecurityAggregatedRecommendationListPage type. +func NewIoTSecurityAggregatedRecommendationListPage(getNextPage func(context.Context, IoTSecurityAggregatedRecommendationList) (IoTSecurityAggregatedRecommendationList, error)) IoTSecurityAggregatedRecommendationListPage { + return IoTSecurityAggregatedRecommendationListPage{fn: getNextPage} +} + +// IoTSecurityAggregatedRecommendationProperties ioT Security solution aggregated recommendation information +type IoTSecurityAggregatedRecommendationProperties struct { + // RecommendationName - Name of the recommendation. + RecommendationName *string `json:"recommendationName,omitempty"` + // RecommendationDisplayName - READ-ONLY; Display name of the recommendation type. + RecommendationDisplayName *string `json:"recommendationDisplayName,omitempty"` + // Description - READ-ONLY; Description of the suspected vulnerability and meaning. + Description *string `json:"description,omitempty"` + // RecommendationTypeID - READ-ONLY; Recommendation-type GUID. + RecommendationTypeID *string `json:"recommendationTypeId,omitempty"` + // DetectedBy - READ-ONLY; Name of the organization that made the recommendation. + DetectedBy *string `json:"detectedBy,omitempty"` + // RemediationSteps - READ-ONLY; Recommended steps for remediation + RemediationSteps *string `json:"remediationSteps,omitempty"` + // ReportedSeverity - READ-ONLY; Assessed recommendation severity. Possible values include: 'ReportedSeverityInformational', 'ReportedSeverityLow', 'ReportedSeverityMedium', 'ReportedSeverityHigh' + ReportedSeverity ReportedSeverity `json:"reportedSeverity,omitempty"` + // HealthyDevices - READ-ONLY; Number of healthy devices within the IoT Security solution. + HealthyDevices *int32 `json:"healthyDevices,omitempty"` + // UnhealthyDeviceCount - READ-ONLY; Number of unhealthy devices within the IoT Security solution. + UnhealthyDeviceCount *int32 `json:"unhealthyDeviceCount,omitempty"` + // LogAnalyticsQuery - READ-ONLY; Log analytics query for getting the list of affected devices/alerts. + LogAnalyticsQuery *string `json:"logAnalyticsQuery,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecurityAggregatedRecommendationProperties. +func (itsarp IoTSecurityAggregatedRecommendationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itsarp.RecommendationName != nil { + objectMap["recommendationName"] = itsarp.RecommendationName + } + return json.Marshal(objectMap) +} + +// IoTSecurityAlertedDevice statistical information about the number of alerts per device during last set +// number of days. +type IoTSecurityAlertedDevice struct { + // DeviceID - READ-ONLY; Device identifier. + DeviceID *string `json:"deviceId,omitempty"` + // AlertsCount - READ-ONLY; Number of alerts raised for this device. + AlertsCount *int32 `json:"alertsCount,omitempty"` +} + +// IoTSecurityDeviceAlert statistical information about the number of alerts per alert type during last set +// number of days +type IoTSecurityDeviceAlert struct { + // AlertDisplayName - READ-ONLY; Display name of the alert + AlertDisplayName *string `json:"alertDisplayName,omitempty"` + // ReportedSeverity - READ-ONLY; Assessed Alert severity. Possible values include: 'ReportedSeverityInformational', 'ReportedSeverityLow', 'ReportedSeverityMedium', 'ReportedSeverityHigh' + ReportedSeverity ReportedSeverity `json:"reportedSeverity,omitempty"` + // AlertsCount - READ-ONLY; Number of alerts raised for this alert type. + AlertsCount *int32 `json:"alertsCount,omitempty"` +} + +// IoTSecurityDeviceRecommendation statistical information about the number of recommendations per device, per +// recommendation type. +type IoTSecurityDeviceRecommendation struct { + // RecommendationDisplayName - READ-ONLY; Display name of the recommendation. + RecommendationDisplayName *string `json:"recommendationDisplayName,omitempty"` + // ReportedSeverity - READ-ONLY; Assessed recommendation severity. Possible values include: 'ReportedSeverityInformational', 'ReportedSeverityLow', 'ReportedSeverityMedium', 'ReportedSeverityHigh' + ReportedSeverity ReportedSeverity `json:"reportedSeverity,omitempty"` + // DevicesCount - READ-ONLY; Number of devices with this recommendation. + DevicesCount *int32 `json:"devicesCount,omitempty"` +} + +// IoTSecuritySolutionAnalyticsModel security analytics of your IoT Security solution +type IoTSecuritySolutionAnalyticsModel struct { + autorest.Response `json:"-"` + // IoTSecuritySolutionAnalyticsModelProperties - Security Solution Aggregated Alert data + *IoTSecuritySolutionAnalyticsModelProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecuritySolutionAnalyticsModel. +func (itssam IoTSecuritySolutionAnalyticsModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itssam.IoTSecuritySolutionAnalyticsModelProperties != nil { + objectMap["properties"] = itssam.IoTSecuritySolutionAnalyticsModelProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IoTSecuritySolutionAnalyticsModel struct. +func (itssam *IoTSecuritySolutionAnalyticsModel) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var ioTSecuritySolutionAnalyticsModelProperties IoTSecuritySolutionAnalyticsModelProperties + err = json.Unmarshal(*v, &ioTSecuritySolutionAnalyticsModelProperties) + if err != nil { + return err + } + itssam.IoTSecuritySolutionAnalyticsModelProperties = &ioTSecuritySolutionAnalyticsModelProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + itssam.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + itssam.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + itssam.Type = &typeVar + } + } + } + + return nil +} + +// IoTSecuritySolutionAnalyticsModelList list of Security analytics of your IoT Security solution +type IoTSecuritySolutionAnalyticsModelList struct { + autorest.Response `json:"-"` + // Value - List of Security analytics of your IoT Security solution + Value *[]IoTSecuritySolutionAnalyticsModel `json:"value,omitempty"` + // NextLink - READ-ONLY; When there is too much alert data for one page, use this URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecuritySolutionAnalyticsModelList. +func (itssaml IoTSecuritySolutionAnalyticsModelList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itssaml.Value != nil { + objectMap["value"] = itssaml.Value + } + return json.Marshal(objectMap) +} + +// IoTSecuritySolutionAnalyticsModelProperties security analytics properties of your IoT Security solution +type IoTSecuritySolutionAnalyticsModelProperties struct { + // Metrics - READ-ONLY; Security analytics of your IoT Security solution. + Metrics *IoTSeverityMetrics `json:"metrics,omitempty"` + // UnhealthyDeviceCount - READ-ONLY; Number of unhealthy devices within your IoT Security solution. + UnhealthyDeviceCount *int32 `json:"unhealthyDeviceCount,omitempty"` + // DevicesMetrics - READ-ONLY; List of device metrics by the aggregation date. + DevicesMetrics *[]IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem `json:"devicesMetrics,omitempty"` + // TopAlertedDevices - List of the 3 devices with the most alerts. + TopAlertedDevices *[]IoTSecurityAlertedDevice `json:"topAlertedDevices,omitempty"` + // MostPrevalentDeviceAlerts - List of the 3 most prevalent device alerts. + MostPrevalentDeviceAlerts *[]IoTSecurityDeviceAlert `json:"mostPrevalentDeviceAlerts,omitempty"` + // MostPrevalentDeviceRecommendations - List of the 3 most prevalent device recommendations. + MostPrevalentDeviceRecommendations *[]IoTSecurityDeviceRecommendation `json:"mostPrevalentDeviceRecommendations,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecuritySolutionAnalyticsModelProperties. +func (itssamp IoTSecuritySolutionAnalyticsModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itssamp.TopAlertedDevices != nil { + objectMap["topAlertedDevices"] = itssamp.TopAlertedDevices + } + if itssamp.MostPrevalentDeviceAlerts != nil { + objectMap["mostPrevalentDeviceAlerts"] = itssamp.MostPrevalentDeviceAlerts + } + if itssamp.MostPrevalentDeviceRecommendations != nil { + objectMap["mostPrevalentDeviceRecommendations"] = itssamp.MostPrevalentDeviceRecommendations + } + return json.Marshal(objectMap) +} + +// IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem ... +type IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem struct { + // Date - Aggregation of IoT Security solution device alert metrics by date. + Date *date.Time `json:"date,omitempty"` + // DevicesMetrics - Device alert count by severity. + DevicesMetrics *IoTSeverityMetrics `json:"devicesMetrics,omitempty"` +} + +// IoTSecuritySolutionModel ioT Security solution configuration and resource information. +type IoTSecuritySolutionModel struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // IoTSecuritySolutionProperties - Security Solution data + *IoTSecuritySolutionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecuritySolutionModel. +func (itssm IoTSecuritySolutionModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itssm.Tags != nil { + objectMap["tags"] = itssm.Tags + } + if itssm.Location != nil { + objectMap["location"] = itssm.Location + } + if itssm.IoTSecuritySolutionProperties != nil { + objectMap["properties"] = itssm.IoTSecuritySolutionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IoTSecuritySolutionModel struct. +func (itssm *IoTSecuritySolutionModel) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + itssm.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + itssm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + itssm.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + itssm.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + itssm.Location = &location + } + case "properties": + if v != nil { + var ioTSecuritySolutionProperties IoTSecuritySolutionProperties + err = json.Unmarshal(*v, &ioTSecuritySolutionProperties) + if err != nil { + return err + } + itssm.IoTSecuritySolutionProperties = &ioTSecuritySolutionProperties + } + } + } + + return nil +} + +// IoTSecuritySolutionProperties security Solution setting data +type IoTSecuritySolutionProperties struct { + // Workspace - Workspace resource ID + Workspace *string `json:"workspace,omitempty"` + // DisplayName - Resource display name. + DisplayName *string `json:"displayName,omitempty"` + // Status - Status of the IoT Security solution. Possible values include: 'SolutionStatusEnabled', 'SolutionStatusDisabled' + Status SolutionStatus `json:"status,omitempty"` + // Export - List of additional options for exporting to workspace data. + Export *[]ExportData `json:"export,omitempty"` + // DisabledDataSources - Disabled data sources. Disabling these data sources compromises the system. + DisabledDataSources *[]DataSource `json:"disabledDataSources,omitempty"` + // IotHubs - IoT Hub resource IDs + IotHubs *[]string `json:"iotHubs,omitempty"` + UserDefinedResources *UserDefinedResourcesProperties `json:"userDefinedResources,omitempty"` + // AutoDiscoveredResources - READ-ONLY; List of resources that were automatically discovered as relevant to the security solution. + AutoDiscoveredResources *[]string `json:"autoDiscoveredResources,omitempty"` + RecommendationsConfiguration *[]RecommendationConfigurationProperties `json:"recommendationsConfiguration,omitempty"` + // UnmaskedIPLoggingStatus - Unmasked IP address logging status. Possible values include: 'UnmaskedIPLoggingStatusDisabled', 'UnmaskedIPLoggingStatusEnabled' + UnmaskedIPLoggingStatus UnmaskedIPLoggingStatus `json:"unmaskedIpLoggingStatus,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecuritySolutionProperties. +func (itssp IoTSecuritySolutionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itssp.Workspace != nil { + objectMap["workspace"] = itssp.Workspace + } + if itssp.DisplayName != nil { + objectMap["displayName"] = itssp.DisplayName + } + if itssp.Status != "" { + objectMap["status"] = itssp.Status + } + if itssp.Export != nil { + objectMap["export"] = itssp.Export + } + if itssp.DisabledDataSources != nil { + objectMap["disabledDataSources"] = itssp.DisabledDataSources + } + if itssp.IotHubs != nil { + objectMap["iotHubs"] = itssp.IotHubs + } + if itssp.UserDefinedResources != nil { + objectMap["userDefinedResources"] = itssp.UserDefinedResources + } + if itssp.RecommendationsConfiguration != nil { + objectMap["recommendationsConfiguration"] = itssp.RecommendationsConfiguration + } + if itssp.UnmaskedIPLoggingStatus != "" { + objectMap["unmaskedIpLoggingStatus"] = itssp.UnmaskedIPLoggingStatus + } + return json.Marshal(objectMap) +} + +// IoTSecuritySolutionsList list of IoT Security solutions. +type IoTSecuritySolutionsList struct { + autorest.Response `json:"-"` + // Value - List of IoT Security solutions + Value *[]IoTSecuritySolutionModel `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for IoTSecuritySolutionsList. +func (itssl IoTSecuritySolutionsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itssl.Value != nil { + objectMap["value"] = itssl.Value + } + return json.Marshal(objectMap) +} + +// IoTSecuritySolutionsListIterator provides access to a complete listing of IoTSecuritySolutionModel values. +type IoTSecuritySolutionsListIterator struct { + i int + page IoTSecuritySolutionsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IoTSecuritySolutionsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IoTSecuritySolutionsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IoTSecuritySolutionsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IoTSecuritySolutionsListIterator) Response() IoTSecuritySolutionsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IoTSecuritySolutionsListIterator) Value() IoTSecuritySolutionModel { + if !iter.page.NotDone() { + return IoTSecuritySolutionModel{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IoTSecuritySolutionsListIterator type. +func NewIoTSecuritySolutionsListIterator(page IoTSecuritySolutionsListPage) IoTSecuritySolutionsListIterator { + return IoTSecuritySolutionsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (itssl IoTSecuritySolutionsList) IsEmpty() bool { + return itssl.Value == nil || len(*itssl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (itssl IoTSecuritySolutionsList) hasNextLink() bool { + return itssl.NextLink != nil && len(*itssl.NextLink) != 0 +} + +// ioTSecuritySolutionsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (itssl IoTSecuritySolutionsList) ioTSecuritySolutionsListPreparer(ctx context.Context) (*http.Request, error) { + if !itssl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(itssl.NextLink))) +} + +// IoTSecuritySolutionsListPage contains a page of IoTSecuritySolutionModel values. +type IoTSecuritySolutionsListPage struct { + fn func(context.Context, IoTSecuritySolutionsList) (IoTSecuritySolutionsList, error) + itssl IoTSecuritySolutionsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IoTSecuritySolutionsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IoTSecuritySolutionsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.itssl) + if err != nil { + return err + } + page.itssl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IoTSecuritySolutionsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IoTSecuritySolutionsListPage) NotDone() bool { + return !page.itssl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IoTSecuritySolutionsListPage) Response() IoTSecuritySolutionsList { + return page.itssl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IoTSecuritySolutionsListPage) Values() []IoTSecuritySolutionModel { + if page.itssl.IsEmpty() { + return nil + } + return *page.itssl.Value +} + +// Creates a new instance of the IoTSecuritySolutionsListPage type. +func NewIoTSecuritySolutionsListPage(getNextPage func(context.Context, IoTSecuritySolutionsList) (IoTSecuritySolutionsList, error)) IoTSecuritySolutionsListPage { + return IoTSecuritySolutionsListPage{fn: getNextPage} +} + +// IoTSeverityMetrics ioT Security solution analytics severity metrics. +type IoTSeverityMetrics struct { + // High - Count of high severity alerts/recommendations. + High *int32 `json:"high,omitempty"` + // Medium - Count of medium severity alerts/recommendations. + Medium *int32 `json:"medium,omitempty"` + // Low - Count of low severity alerts/recommendations. + Low *int32 `json:"low,omitempty"` +} + +// JitNetworkAccessPoliciesList ... +type JitNetworkAccessPoliciesList struct { + autorest.Response `json:"-"` + Value *[]JitNetworkAccessPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JitNetworkAccessPoliciesList. +func (jnapl JitNetworkAccessPoliciesList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jnapl.Value != nil { + objectMap["value"] = jnapl.Value + } + return json.Marshal(objectMap) +} + +// JitNetworkAccessPoliciesListIterator provides access to a complete listing of JitNetworkAccessPolicy values. +type JitNetworkAccessPoliciesListIterator struct { + i int + page JitNetworkAccessPoliciesListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JitNetworkAccessPoliciesListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JitNetworkAccessPoliciesListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JitNetworkAccessPoliciesListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JitNetworkAccessPoliciesListIterator) Response() JitNetworkAccessPoliciesList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JitNetworkAccessPoliciesListIterator) Value() JitNetworkAccessPolicy { + if !iter.page.NotDone() { + return JitNetworkAccessPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the JitNetworkAccessPoliciesListIterator type. +func NewJitNetworkAccessPoliciesListIterator(page JitNetworkAccessPoliciesListPage) JitNetworkAccessPoliciesListIterator { + return JitNetworkAccessPoliciesListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jnapl JitNetworkAccessPoliciesList) IsEmpty() bool { + return jnapl.Value == nil || len(*jnapl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jnapl JitNetworkAccessPoliciesList) hasNextLink() bool { + return jnapl.NextLink != nil && len(*jnapl.NextLink) != 0 +} + +// jitNetworkAccessPoliciesListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jnapl JitNetworkAccessPoliciesList) jitNetworkAccessPoliciesListPreparer(ctx context.Context) (*http.Request, error) { + if !jnapl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jnapl.NextLink))) +} + +// JitNetworkAccessPoliciesListPage contains a page of JitNetworkAccessPolicy values. +type JitNetworkAccessPoliciesListPage struct { + fn func(context.Context, JitNetworkAccessPoliciesList) (JitNetworkAccessPoliciesList, error) + jnapl JitNetworkAccessPoliciesList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JitNetworkAccessPoliciesListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JitNetworkAccessPoliciesListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jnapl) + if err != nil { + return err + } + page.jnapl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *JitNetworkAccessPoliciesListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JitNetworkAccessPoliciesListPage) NotDone() bool { + return !page.jnapl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JitNetworkAccessPoliciesListPage) Response() JitNetworkAccessPoliciesList { + return page.jnapl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JitNetworkAccessPoliciesListPage) Values() []JitNetworkAccessPolicy { + if page.jnapl.IsEmpty() { + return nil + } + return *page.jnapl.Value +} + +// Creates a new instance of the JitNetworkAccessPoliciesListPage type. +func NewJitNetworkAccessPoliciesListPage(getNextPage func(context.Context, JitNetworkAccessPoliciesList) (JitNetworkAccessPoliciesList, error)) JitNetworkAccessPoliciesListPage { + return JitNetworkAccessPoliciesListPage{fn: getNextPage} +} + +// JitNetworkAccessPolicy ... +type JitNetworkAccessPolicy struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Kind - Kind of the resource + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + *JitNetworkAccessPolicyProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for JitNetworkAccessPolicy. +func (jnap JitNetworkAccessPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jnap.Kind != nil { + objectMap["kind"] = jnap.Kind + } + if jnap.JitNetworkAccessPolicyProperties != nil { + objectMap["properties"] = jnap.JitNetworkAccessPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JitNetworkAccessPolicy struct. +func (jnap *JitNetworkAccessPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + jnap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + jnap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + jnap.Type = &typeVar + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + jnap.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + jnap.Location = &location + } + case "properties": + if v != nil { + var jitNetworkAccessPolicyProperties JitNetworkAccessPolicyProperties + err = json.Unmarshal(*v, &jitNetworkAccessPolicyProperties) + if err != nil { + return err + } + jnap.JitNetworkAccessPolicyProperties = &jitNetworkAccessPolicyProperties + } + } + } + + return nil +} + +// JitNetworkAccessPolicyInitiatePort ... +type JitNetworkAccessPolicyInitiatePort struct { + Number *int32 `json:"number,omitempty"` + // AllowedSourceAddressPrefix - Source of the allowed traffic. If omitted, the request will be for the source IP address of the initiate request. + AllowedSourceAddressPrefix *string `json:"allowedSourceAddressPrefix,omitempty"` + // EndTimeUtc - The time to close the request in UTC + EndTimeUtc *date.Time `json:"endTimeUtc,omitempty"` +} + +// JitNetworkAccessPolicyInitiateRequest ... +type JitNetworkAccessPolicyInitiateRequest struct { + // VirtualMachines - A list of virtual machines & ports to open access for + VirtualMachines *[]JitNetworkAccessPolicyInitiateVirtualMachine `json:"virtualMachines,omitempty"` + // Justification - The justification for making the initiate request + Justification *string `json:"justification,omitempty"` +} + +// JitNetworkAccessPolicyInitiateVirtualMachine ... +type JitNetworkAccessPolicyInitiateVirtualMachine struct { + // ID - Resource ID of the virtual machine that is linked to this policy + ID *string `json:"id,omitempty"` + // Ports - The ports to open for the resource with the `id` + Ports *[]JitNetworkAccessPolicyInitiatePort `json:"ports,omitempty"` +} + +// JitNetworkAccessPolicyProperties ... +type JitNetworkAccessPolicyProperties struct { + // VirtualMachines - Configurations for Microsoft.Compute/virtualMachines resource type. + VirtualMachines *[]JitNetworkAccessPolicyVirtualMachine `json:"virtualMachines,omitempty"` + Requests *[]JitNetworkAccessRequest `json:"requests,omitempty"` + // ProvisioningState - READ-ONLY; Gets the provisioning state of the Just-in-Time policy. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for JitNetworkAccessPolicyProperties. +func (jnapp JitNetworkAccessPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jnapp.VirtualMachines != nil { + objectMap["virtualMachines"] = jnapp.VirtualMachines + } + if jnapp.Requests != nil { + objectMap["requests"] = jnapp.Requests + } + return json.Marshal(objectMap) +} + +// JitNetworkAccessPolicyVirtualMachine ... +type JitNetworkAccessPolicyVirtualMachine struct { + // ID - Resource ID of the virtual machine that is linked to this policy + ID *string `json:"id,omitempty"` + // Ports - Port configurations for the virtual machine + Ports *[]JitNetworkAccessPortRule `json:"ports,omitempty"` + // PublicIPAddress - Public IP address of the Azure Firewall that is linked to this policy, if applicable + PublicIPAddress *string `json:"publicIpAddress,omitempty"` +} + +// JitNetworkAccessPortRule ... +type JitNetworkAccessPortRule struct { + Number *int32 `json:"number,omitempty"` + // Protocol - Possible values include: 'TCP', 'UDP', 'All' + Protocol Protocol `json:"protocol,omitempty"` + // AllowedSourceAddressPrefix - Mutually exclusive with the "allowedSourceAddressPrefixes" parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16". + AllowedSourceAddressPrefix *string `json:"allowedSourceAddressPrefix,omitempty"` + // AllowedSourceAddressPrefixes - Mutually exclusive with the "allowedSourceAddressPrefix" parameter. + AllowedSourceAddressPrefixes *[]string `json:"allowedSourceAddressPrefixes,omitempty"` + // MaxRequestAccessDuration - Maximum duration requests can be made for. In ISO 8601 duration format. Minimum 5 minutes, maximum 1 day + MaxRequestAccessDuration *string `json:"maxRequestAccessDuration,omitempty"` +} + +// JitNetworkAccessRequest ... +type JitNetworkAccessRequest struct { + autorest.Response `json:"-"` + VirtualMachines *[]JitNetworkAccessRequestVirtualMachine `json:"virtualMachines,omitempty"` + // StartTimeUtc - The start time of the request in UTC + StartTimeUtc *date.Time `json:"startTimeUtc,omitempty"` + // Requestor - The identity of the person who made the request + Requestor *string `json:"requestor,omitempty"` + // Justification - The justification for making the initiate request + Justification *string `json:"justification,omitempty"` +} + +// JitNetworkAccessRequestPort ... +type JitNetworkAccessRequestPort struct { + Number *int32 `json:"number,omitempty"` + // AllowedSourceAddressPrefix - Mutually exclusive with the "allowedSourceAddressPrefixes" parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16". + AllowedSourceAddressPrefix *string `json:"allowedSourceAddressPrefix,omitempty"` + // AllowedSourceAddressPrefixes - Mutually exclusive with the "allowedSourceAddressPrefix" parameter. + AllowedSourceAddressPrefixes *[]string `json:"allowedSourceAddressPrefixes,omitempty"` + // EndTimeUtc - The date & time at which the request ends in UTC + EndTimeUtc *date.Time `json:"endTimeUtc,omitempty"` + // Status - The status of the port. Possible values include: 'Revoked', 'Initiated' + Status Status `json:"status,omitempty"` + // StatusReason - A description of why the `status` has its value. Possible values include: 'StatusReasonExpired', 'StatusReasonUserRequested', 'StatusReasonNewerRequestInitiated' + StatusReason StatusReason `json:"statusReason,omitempty"` + // MappedPort - The port which is mapped to this port's `number` in the Azure Firewall, if applicable + MappedPort *int32 `json:"mappedPort,omitempty"` +} + +// JitNetworkAccessRequestVirtualMachine ... +type JitNetworkAccessRequestVirtualMachine struct { + // ID - Resource ID of the virtual machine that is linked to this policy + ID *string `json:"id,omitempty"` + // Ports - The ports that were opened for the virtual machine + Ports *[]JitNetworkAccessRequestPort `json:"ports,omitempty"` +} + +// Kind describes an Azure resource with kind +type Kind struct { + // Kind - Kind of the resource + Kind *string `json:"kind,omitempty"` +} + +// BasicListCustomAlertRule a List custom alert rule. +type BasicListCustomAlertRule interface { + AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) + AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) + AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) + AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) + AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) + AsProcessNotAllowed() (*ProcessNotAllowed, bool) + AsListCustomAlertRule() (*ListCustomAlertRule, bool) +} + +// ListCustomAlertRule a List custom alert rule. +type ListCustomAlertRule struct { + // ValueType - READ-ONLY; The value type of the items in the list. Possible values include: 'ValueTypeIPCidr', 'ValueTypeString' + ValueType ValueType `json:"valueType,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +func unmarshalBasicListCustomAlertRule(body []byte) (BasicListCustomAlertRule, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["ruleType"] { + case string(RuleTypeAllowlistCustomAlertRule): + var acar AllowlistCustomAlertRule + err := json.Unmarshal(body, &acar) + return acar, err + case string(RuleTypeDenylistCustomAlertRule): + var dcar DenylistCustomAlertRule + err := json.Unmarshal(body, &dcar) + return dcar, err + case string(RuleTypeConnectionToIPNotAllowed): + var ctina ConnectionToIPNotAllowed + err := json.Unmarshal(body, &ctina) + return ctina, err + case string(RuleTypeLocalUserNotAllowed): + var luna LocalUserNotAllowed + err := json.Unmarshal(body, &luna) + return luna, err + case string(RuleTypeProcessNotAllowed): + var pna ProcessNotAllowed + err := json.Unmarshal(body, &pna) + return pna, err + default: + var lcar ListCustomAlertRule + err := json.Unmarshal(body, &lcar) + return lcar, err + } +} +func unmarshalBasicListCustomAlertRuleArray(body []byte) ([]BasicListCustomAlertRule, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + lcarArray := make([]BasicListCustomAlertRule, len(rawMessages)) + + for index, rawMessage := range rawMessages { + lcar, err := unmarshalBasicListCustomAlertRule(*rawMessage) + if err != nil { + return nil, err + } + lcarArray[index] = lcar + } + return lcarArray, nil +} + +// MarshalJSON is the custom marshaler for ListCustomAlertRule. +func (lcar ListCustomAlertRule) MarshalJSON() ([]byte, error) { + lcar.RuleType = RuleTypeListCustomAlertRule + objectMap := make(map[string]interface{}) + if lcar.IsEnabled != nil { + objectMap["isEnabled"] = lcar.IsEnabled + } + if lcar.RuleType != "" { + objectMap["ruleType"] = lcar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return &lcar, true +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return &lcar, true +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for ListCustomAlertRule. +func (lcar ListCustomAlertRule) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &lcar, true +} + +// LocalUserNotAllowed login by a local user that isn't allowed. Allow list consists of login names to allow. +type LocalUserNotAllowed struct { + // AllowlistValues - The values to allow. The format of the values depends on the rule type. + AllowlistValues *[]string `json:"allowlistValues,omitempty"` + // ValueType - READ-ONLY; The value type of the items in the list. Possible values include: 'ValueTypeIPCidr', 'ValueTypeString' + ValueType ValueType `json:"valueType,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) MarshalJSON() ([]byte, error) { + luna.RuleType = RuleTypeLocalUserNotAllowed + objectMap := make(map[string]interface{}) + if luna.AllowlistValues != nil { + objectMap["allowlistValues"] = luna.AllowlistValues + } + if luna.IsEnabled != nil { + objectMap["isEnabled"] = luna.IsEnabled + } + if luna.RuleType != "" { + objectMap["ruleType"] = luna.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return &luna, true +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return &luna, true +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return &luna, true +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for LocalUserNotAllowed. +func (luna LocalUserNotAllowed) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &luna, true +} + +// Location describes an Azure resource with location +type Location struct { + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` +} + +// MqttC2DMessagesNotInAllowedRange number of cloud to device messages (MQTT protocol) is not in allowed range. +type MqttC2DMessagesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { + mcmniar.RuleType = RuleTypeMqttC2DMessagesNotInAllowedRange + objectMap := make(map[string]interface{}) + if mcmniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = mcmniar.TimeWindowSize + } + if mcmniar.MinThreshold != nil { + objectMap["minThreshold"] = mcmniar.MinThreshold + } + if mcmniar.MaxThreshold != nil { + objectMap["maxThreshold"] = mcmniar.MaxThreshold + } + if mcmniar.IsEnabled != nil { + objectMap["isEnabled"] = mcmniar.IsEnabled + } + if mcmniar.RuleType != "" { + objectMap["ruleType"] = mcmniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &mcmniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &mcmniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return &mcmniar, true +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DMessagesNotInAllowedRange. +func (mcmniar MqttC2DMessagesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &mcmniar, true +} + +// MqttC2DRejectedMessagesNotInAllowedRange number of rejected cloud to device messages (MQTT protocol) is not +// in allowed range. +type MqttC2DRejectedMessagesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { + mcrmniar.RuleType = RuleTypeMqttC2DRejectedMessagesNotInAllowedRange + objectMap := make(map[string]interface{}) + if mcrmniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = mcrmniar.TimeWindowSize + } + if mcrmniar.MinThreshold != nil { + objectMap["minThreshold"] = mcrmniar.MinThreshold + } + if mcrmniar.MaxThreshold != nil { + objectMap["maxThreshold"] = mcrmniar.MaxThreshold + } + if mcrmniar.IsEnabled != nil { + objectMap["isEnabled"] = mcrmniar.IsEnabled + } + if mcrmniar.RuleType != "" { + objectMap["ruleType"] = mcrmniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &mcrmniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &mcrmniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return &mcrmniar, true +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for MqttC2DRejectedMessagesNotInAllowedRange. +func (mcrmniar MqttC2DRejectedMessagesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &mcrmniar, true +} + +// MqttD2CMessagesNotInAllowedRange number of device to cloud messages (MQTT protocol) is not in allowed range. +type MqttD2CMessagesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) MarshalJSON() ([]byte, error) { + mdmniar.RuleType = RuleTypeMqttD2CMessagesNotInAllowedRange + objectMap := make(map[string]interface{}) + if mdmniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = mdmniar.TimeWindowSize + } + if mdmniar.MinThreshold != nil { + objectMap["minThreshold"] = mdmniar.MinThreshold + } + if mdmniar.MaxThreshold != nil { + objectMap["maxThreshold"] = mdmniar.MaxThreshold + } + if mdmniar.IsEnabled != nil { + objectMap["isEnabled"] = mdmniar.IsEnabled + } + if mdmniar.RuleType != "" { + objectMap["ruleType"] = mdmniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &mdmniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &mdmniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return &mdmniar, true +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for MqttD2CMessagesNotInAllowedRange. +func (mdmniar MqttD2CMessagesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &mdmniar, true +} + +// BasicOnPremiseResourceDetails details of the On Premise resource that was assessed +type BasicOnPremiseResourceDetails interface { + AsOnPremiseSQLResourceDetails() (*OnPremiseSQLResourceDetails, bool) + AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) +} + +// OnPremiseResourceDetails details of the On Premise resource that was assessed +type OnPremiseResourceDetails struct { + // WorkspaceID - Azure resource Id of the workspace the machine is attached to + WorkspaceID *string `json:"workspaceId,omitempty"` + // Vmuuid - The unique Id of the machine + Vmuuid *string `json:"vmuuid,omitempty"` + // SourceComputerID - The oms agent Id installed on the machine + SourceComputerID *string `json:"sourceComputerId,omitempty"` + // MachineName - The name of the machine + MachineName *string `json:"machineName,omitempty"` + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremiseSQL', 'SourceOnPremise', 'SourceAzure' + Source Source `json:"source,omitempty"` +} + +func unmarshalBasicOnPremiseResourceDetails(body []byte) (BasicOnPremiseResourceDetails, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["source"] { + case string(SourceOnPremiseSQL): + var opsrd OnPremiseSQLResourceDetails + err := json.Unmarshal(body, &opsrd) + return opsrd, err + default: + var oprd OnPremiseResourceDetails + err := json.Unmarshal(body, &oprd) + return oprd, err + } +} +func unmarshalBasicOnPremiseResourceDetailsArray(body []byte) ([]BasicOnPremiseResourceDetails, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + oprdArray := make([]BasicOnPremiseResourceDetails, len(rawMessages)) + + for index, rawMessage := range rawMessages { + oprd, err := unmarshalBasicOnPremiseResourceDetails(*rawMessage) + if err != nil { + return nil, err + } + oprdArray[index] = oprd + } + return oprdArray, nil +} + +// MarshalJSON is the custom marshaler for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) MarshalJSON() ([]byte, error) { + oprd.Source = SourceOnPremise + objectMap := make(map[string]interface{}) + if oprd.WorkspaceID != nil { + objectMap["workspaceId"] = oprd.WorkspaceID + } + if oprd.Vmuuid != nil { + objectMap["vmuuid"] = oprd.Vmuuid + } + if oprd.SourceComputerID != nil { + objectMap["sourceComputerId"] = oprd.SourceComputerID + } + if oprd.MachineName != nil { + objectMap["machineName"] = oprd.MachineName + } + if oprd.Source != "" { + objectMap["source"] = oprd.Source + } + return json.Marshal(objectMap) +} + +// AsOnPremiseSQLResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsOnPremiseSQLResourceDetails() (*OnPremiseSQLResourceDetails, bool) { + return nil, false +} + +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { + return &oprd, true +} + +// AsBasicOnPremiseResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsBasicOnPremiseResourceDetails() (BasicOnPremiseResourceDetails, bool) { + return &oprd, true +} + +// AsAzureResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { + return nil, false +} + +// AsResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { + return nil, false +} + +// AsBasicResourceDetails is the BasicResourceDetails implementation for OnPremiseResourceDetails. +func (oprd OnPremiseResourceDetails) AsBasicResourceDetails() (BasicResourceDetails, bool) { + return &oprd, true +} + +// OnPremiseSQLResourceDetails details of the On Premise Sql resource that was assessed +type OnPremiseSQLResourceDetails struct { + // ServerName - The Sql server name installed on the machine + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - The Sql database name installed on the machine + DatabaseName *string `json:"databaseName,omitempty"` + // WorkspaceID - Azure resource Id of the workspace the machine is attached to + WorkspaceID *string `json:"workspaceId,omitempty"` + // Vmuuid - The unique Id of the machine + Vmuuid *string `json:"vmuuid,omitempty"` + // SourceComputerID - The oms agent Id installed on the machine + SourceComputerID *string `json:"sourceComputerId,omitempty"` + // MachineName - The name of the machine + MachineName *string `json:"machineName,omitempty"` + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremiseSQL', 'SourceOnPremise', 'SourceAzure' + Source Source `json:"source,omitempty"` +} + +// MarshalJSON is the custom marshaler for OnPremiseSQLResourceDetails. +func (opsrd OnPremiseSQLResourceDetails) MarshalJSON() ([]byte, error) { + opsrd.Source = SourceOnPremiseSQL + objectMap := make(map[string]interface{}) + if opsrd.ServerName != nil { + objectMap["serverName"] = opsrd.ServerName + } + if opsrd.DatabaseName != nil { + objectMap["databaseName"] = opsrd.DatabaseName + } + if opsrd.WorkspaceID != nil { + objectMap["workspaceId"] = opsrd.WorkspaceID + } + if opsrd.Vmuuid != nil { + objectMap["vmuuid"] = opsrd.Vmuuid + } + if opsrd.SourceComputerID != nil { + objectMap["sourceComputerId"] = opsrd.SourceComputerID + } + if opsrd.MachineName != nil { + objectMap["machineName"] = opsrd.MachineName + } + if opsrd.Source != "" { + objectMap["source"] = opsrd.Source + } + return json.Marshal(objectMap) +} + +// AsOnPremiseSQLResourceDetails is the BasicResourceDetails implementation for OnPremiseSQLResourceDetails. +func (opsrd OnPremiseSQLResourceDetails) AsOnPremiseSQLResourceDetails() (*OnPremiseSQLResourceDetails, bool) { + return &opsrd, true +} + +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for OnPremiseSQLResourceDetails. +func (opsrd OnPremiseSQLResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { + return nil, false +} + +// AsBasicOnPremiseResourceDetails is the BasicResourceDetails implementation for OnPremiseSQLResourceDetails. +func (opsrd OnPremiseSQLResourceDetails) AsBasicOnPremiseResourceDetails() (BasicOnPremiseResourceDetails, bool) { + return &opsrd, true +} + +// AsAzureResourceDetails is the BasicResourceDetails implementation for OnPremiseSQLResourceDetails. +func (opsrd OnPremiseSQLResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { + return nil, false +} + +// AsResourceDetails is the BasicResourceDetails implementation for OnPremiseSQLResourceDetails. +func (opsrd OnPremiseSQLResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { + return nil, false +} + +// AsBasicResourceDetails is the BasicResourceDetails implementation for OnPremiseSQLResourceDetails. +func (opsrd OnPremiseSQLResourceDetails) AsBasicResourceDetails() (BasicResourceDetails, bool) { + return &opsrd, true +} + +// Operation possible operation in the REST API of Microsoft.Security +type Operation struct { + // Name - READ-ONLY; Name of the operation + Name *string `json:"name,omitempty"` + // Origin - READ-ONLY; Where the operation is originated + Origin *string `json:"origin,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Display != nil { + objectMap["display"] = o.Display + } + return json.Marshal(objectMap) +} + +// OperationDisplay security operation display +type OperationDisplay struct { + // Provider - READ-ONLY; The resource provider for the operation. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; The display name of the resource the operation applies to. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; The display name of the security operation. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; The description of the operation. + Description *string `json:"description,omitempty"` +} + +// OperationList list of possible operations for Microsoft.Security resource provider +type OperationList struct { + autorest.Response `json:"-"` + // Value - List of Security operations + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationList. +func (ol OperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ol.Value != nil { + objectMap["value"] = ol.Value + } + return json.Marshal(objectMap) +} + +// OperationListIterator provides access to a complete listing of Operation values. +type OperationListIterator struct { + i int + page OperationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListIterator) Response() OperationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListIterator type. +func NewOperationListIterator(page OperationListPage) OperationListIterator { + return OperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ol OperationList) hasNextLink() bool { + return ol.NextLink != nil && len(*ol.NextLink) != 0 +} + +// operationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { + if !ol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationListPage contains a page of Operation values. +type OperationListPage struct { + fn func(context.Context, OperationList) (OperationList, error) + ol OperationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ol) + if err != nil { + return err + } + page.ol = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListPage) Response() OperationList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListPage) Values() []Operation { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationListPage type. +func NewOperationListPage(getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{fn: getNextPage} +} + +// PathRecommendation represents a path that is recommended to be allowed and its properties +type PathRecommendation struct { + // Path - The full path of the file, or an identifier of the application + Path *string `json:"path,omitempty"` + // Action - Possible values include: 'Recommended', 'Add', 'Remove' + Action Action `json:"action,omitempty"` + // Type - Possible values include: 'File', 'FileHash', 'PublisherSignature', 'ProductSignature', 'BinarySignature', 'VersionAndAboveSignature' + Type Type `json:"type,omitempty"` + PublisherInfo *PublisherInfo `json:"publisherInfo,omitempty"` + // Common - Whether the application is commonly run on the machine + Common *bool `json:"common,omitempty"` + UserSids *[]string `json:"userSids,omitempty"` + Usernames *[]UserRecommendation `json:"usernames,omitempty"` + // FileType - Possible values include: 'FileTypeExe', 'FileTypeDll', 'FileTypeMsi', 'FileTypeScript', 'FileTypeExecutable', 'FileTypeUnknown' + FileType FileType `json:"fileType,omitempty"` + // ConfigurationStatus - Possible values include: 'ConfigurationStatus1Configured', 'ConfigurationStatus1NotConfigured', 'ConfigurationStatus1InProgress', 'ConfigurationStatus1Failed', 'ConfigurationStatus1NoStatus' + ConfigurationStatus ConfigurationStatus1 `json:"configurationStatus,omitempty"` +} + +// Pricing azure Security Center is provided in two pricing tiers: free and standard, with the standard tier +// available with a trial period. The standard tier offers advanced security capabilities, while the free tier +// offers basic security features. +type Pricing struct { + autorest.Response `json:"-"` + // PricingProperties - Pricing data + *PricingProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Pricing. +func (p Pricing) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.PricingProperties != nil { + objectMap["properties"] = p.PricingProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Pricing struct. +func (p *Pricing) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var pricingProperties PricingProperties + err = json.Unmarshal(*v, &pricingProperties) + if err != nil { + return err + } + p.PricingProperties = &pricingProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + p.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + p.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + p.Type = &typeVar + } + } + } + + return nil +} + +// PricingList list of pricing configurations response. +type PricingList struct { + autorest.Response `json:"-"` + // Value - List of pricing configurations + Value *[]Pricing `json:"value,omitempty"` +} + +// PricingProperties pricing properties for the relevant scope +type PricingProperties struct { + // PricingTier - The pricing tier value. Azure Security Center is provided in two pricing tiers: free and standard, with the standard tier available with a trial period. The standard tier offers advanced security capabilities, while the free tier offers basic security features. Possible values include: 'Free', 'Standard' + PricingTier PricingTier `json:"pricingTier,omitempty"` + // FreeTrialRemainingTime - READ-ONLY; The duration left for the subscriptions free trial period - in ISO 8601 format (e.g. P3Y6M4DT12H30M5S). + FreeTrialRemainingTime *string `json:"freeTrialRemainingTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for PricingProperties. +func (pp PricingProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pp.PricingTier != "" { + objectMap["pricingTier"] = pp.PricingTier + } + return json.Marshal(objectMap) +} + +// ProcessNotAllowed execution of a process that isn't allowed. Allow list consists of process names to allow. +type ProcessNotAllowed struct { + // AllowlistValues - The values to allow. The format of the values depends on the rule type. + AllowlistValues *[]string `json:"allowlistValues,omitempty"` + // ValueType - READ-ONLY; The value type of the items in the list. Possible values include: 'ValueTypeIPCidr', 'ValueTypeString' + ValueType ValueType `json:"valueType,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProcessNotAllowed. +func (pna ProcessNotAllowed) MarshalJSON() ([]byte, error) { + pna.RuleType = RuleTypeProcessNotAllowed + objectMap := make(map[string]interface{}) + if pna.AllowlistValues != nil { + objectMap["allowlistValues"] = pna.AllowlistValues + } + if pna.IsEnabled != nil { + objectMap["isEnabled"] = pna.IsEnabled + } + if pna.RuleType != "" { + objectMap["ruleType"] = pna.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return &pna, true +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return &pna, true +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return &pna, true +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for ProcessNotAllowed. +func (pna ProcessNotAllowed) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &pna, true +} + +// ProtectionMode the protection mode of the collection/file types. Exe/Msi/Script are used for Windows, +// Executable is used for Linux. +type ProtectionMode struct { + // Exe - Possible values include: 'ExeAudit', 'ExeEnforce', 'ExeNone' + Exe Exe `json:"exe,omitempty"` + // Msi - Possible values include: 'MsiAudit', 'MsiEnforce', 'MsiNone' + Msi Msi `json:"msi,omitempty"` + // Script - Possible values include: 'ScriptAudit', 'ScriptEnforce', 'ScriptNone' + Script Script `json:"script,omitempty"` + // Executable - Possible values include: 'ExecutableAudit', 'ExecutableEnforce', 'ExecutableNone' + Executable Executable `json:"executable,omitempty"` +} + +// ProxyServerProperties for a non-Azure machine that is not connected directly to the internet, specify a +// proxy server that the non-Azure machine can use. +type ProxyServerProperties struct { + // IP - Proxy server IP + IP *string `json:"ip,omitempty"` + // Port - Proxy server port + Port *string `json:"port,omitempty"` +} + +// PublisherInfo represents the publisher information of a process/rule +type PublisherInfo struct { + // PublisherName - The Subject field of the x.509 certificate used to sign the code, using the following fields - O = Organization, L = Locality, S = State or Province, and C = Country + PublisherName *string `json:"publisherName,omitempty"` + // ProductName - The product name taken from the file's version resource + ProductName *string `json:"productName,omitempty"` + // BinaryName - The "OriginalName" field taken from the file's version resource + BinaryName *string `json:"binaryName,omitempty"` + // Version - The binary file version taken from the file's version resource + Version *string `json:"version,omitempty"` +} + +// QueuePurgesNotInAllowedRange number of device queue purges is not in allowed range. +type QueuePurgesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) MarshalJSON() ([]byte, error) { + qpniar.RuleType = RuleTypeQueuePurgesNotInAllowedRange + objectMap := make(map[string]interface{}) + if qpniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = qpniar.TimeWindowSize + } + if qpniar.MinThreshold != nil { + objectMap["minThreshold"] = qpniar.MinThreshold + } + if qpniar.MaxThreshold != nil { + objectMap["maxThreshold"] = qpniar.MaxThreshold + } + if qpniar.IsEnabled != nil { + objectMap["isEnabled"] = qpniar.IsEnabled + } + if qpniar.RuleType != "" { + objectMap["ruleType"] = qpniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &qpniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &qpniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return &qpniar, true +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for QueuePurgesNotInAllowedRange. +func (qpniar QueuePurgesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &qpniar, true +} + +// RecommendationConfigurationProperties the type of IoT Security recommendation. +type RecommendationConfigurationProperties struct { + // RecommendationType - The type of IoT Security recommendation. Possible values include: 'IoTACRAuthentication', 'IoTAgentSendsUnutilizedMessages', 'IoTBaseline', 'IoTEdgeHubMemOptimize', 'IoTEdgeLoggingOptions', 'IoTInconsistentModuleSettings', 'IoTInstallAgent', 'IoTIPFilterDenyAll', 'IoTIPFilterPermissiveRule', 'IoTOpenPorts', 'IoTPermissiveFirewallPolicy', 'IoTPermissiveInputFirewallRules', 'IoTPermissiveOutputFirewallRules', 'IoTPrivilegedDockerOptions', 'IoTSharedCredentials', 'IoTVulnerableTLSCipherSuite' + RecommendationType RecommendationType `json:"recommendationType,omitempty"` + // Name - READ-ONLY + Name *string `json:"name,omitempty"` + // Status - Recommendation status. When the recommendation status is disabled recommendations are not generated. Possible values include: 'Disabled', 'Enabled' + Status RecommendationConfigStatus `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendationConfigurationProperties. +func (rcp RecommendationConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcp.RecommendationType != "" { + objectMap["recommendationType"] = rcp.RecommendationType + } + if rcp.Status != "" { + objectMap["status"] = rcp.Status + } + return json.Marshal(objectMap) +} + +// RegulatoryComplianceAssessment regulatory compliance assessment details and state +type RegulatoryComplianceAssessment struct { + autorest.Response `json:"-"` + // RegulatoryComplianceAssessmentProperties - Regulatory compliance assessment data + *RegulatoryComplianceAssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceAssessment. +func (rca RegulatoryComplianceAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rca.RegulatoryComplianceAssessmentProperties != nil { + objectMap["properties"] = rca.RegulatoryComplianceAssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegulatoryComplianceAssessment struct. +func (rca *RegulatoryComplianceAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var regulatoryComplianceAssessmentProperties RegulatoryComplianceAssessmentProperties + err = json.Unmarshal(*v, ®ulatoryComplianceAssessmentProperties) + if err != nil { + return err + } + rca.RegulatoryComplianceAssessmentProperties = ®ulatoryComplianceAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rca.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rca.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rca.Type = &typeVar + } + } + } + + return nil +} + +// RegulatoryComplianceAssessmentList list of regulatory compliance assessment response +type RegulatoryComplianceAssessmentList struct { + autorest.Response `json:"-"` + Value *[]RegulatoryComplianceAssessment `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceAssessmentList. +func (rcal RegulatoryComplianceAssessmentList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcal.Value != nil { + objectMap["value"] = rcal.Value + } + return json.Marshal(objectMap) +} + +// RegulatoryComplianceAssessmentListIterator provides access to a complete listing of +// RegulatoryComplianceAssessment values. +type RegulatoryComplianceAssessmentListIterator struct { + i int + page RegulatoryComplianceAssessmentListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RegulatoryComplianceAssessmentListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RegulatoryComplianceAssessmentListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegulatoryComplianceAssessmentListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RegulatoryComplianceAssessmentListIterator) Response() RegulatoryComplianceAssessmentList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RegulatoryComplianceAssessmentListIterator) Value() RegulatoryComplianceAssessment { + if !iter.page.NotDone() { + return RegulatoryComplianceAssessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegulatoryComplianceAssessmentListIterator type. +func NewRegulatoryComplianceAssessmentListIterator(page RegulatoryComplianceAssessmentListPage) RegulatoryComplianceAssessmentListIterator { + return RegulatoryComplianceAssessmentListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rcal RegulatoryComplianceAssessmentList) IsEmpty() bool { + return rcal.Value == nil || len(*rcal.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rcal RegulatoryComplianceAssessmentList) hasNextLink() bool { + return rcal.NextLink != nil && len(*rcal.NextLink) != 0 +} + +// regulatoryComplianceAssessmentListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rcal RegulatoryComplianceAssessmentList) regulatoryComplianceAssessmentListPreparer(ctx context.Context) (*http.Request, error) { + if !rcal.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rcal.NextLink))) +} + +// RegulatoryComplianceAssessmentListPage contains a page of RegulatoryComplianceAssessment values. +type RegulatoryComplianceAssessmentListPage struct { + fn func(context.Context, RegulatoryComplianceAssessmentList) (RegulatoryComplianceAssessmentList, error) + rcal RegulatoryComplianceAssessmentList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RegulatoryComplianceAssessmentListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rcal) + if err != nil { + return err + } + page.rcal = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegulatoryComplianceAssessmentListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegulatoryComplianceAssessmentListPage) NotDone() bool { + return !page.rcal.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegulatoryComplianceAssessmentListPage) Response() RegulatoryComplianceAssessmentList { + return page.rcal +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegulatoryComplianceAssessmentListPage) Values() []RegulatoryComplianceAssessment { + if page.rcal.IsEmpty() { + return nil + } + return *page.rcal.Value +} + +// Creates a new instance of the RegulatoryComplianceAssessmentListPage type. +func NewRegulatoryComplianceAssessmentListPage(getNextPage func(context.Context, RegulatoryComplianceAssessmentList) (RegulatoryComplianceAssessmentList, error)) RegulatoryComplianceAssessmentListPage { + return RegulatoryComplianceAssessmentListPage{fn: getNextPage} +} + +// RegulatoryComplianceAssessmentProperties regulatory compliance assessment data +type RegulatoryComplianceAssessmentProperties struct { + // Description - READ-ONLY; The description of the regulatory compliance assessment + Description *string `json:"description,omitempty"` + // AssessmentType - READ-ONLY; The expected type of assessment contained in the AssessmentDetailsLink + AssessmentType *string `json:"assessmentType,omitempty"` + // AssessmentDetailsLink - READ-ONLY; Link to more detailed assessment results data. The response type will be according to the assessmentType field + AssessmentDetailsLink *string `json:"assessmentDetailsLink,omitempty"` + // State - Aggregative state based on the assessment's scanned resources states. Possible values include: 'StatePassed', 'StateFailed', 'StateSkipped', 'StateUnsupported' + State State `json:"state,omitempty"` + // PassedResources - READ-ONLY; The given assessment's related resources count with passed state. + PassedResources *int32 `json:"passedResources,omitempty"` + // FailedResources - READ-ONLY; The given assessment's related resources count with failed state. + FailedResources *int32 `json:"failedResources,omitempty"` + // SkippedResources - READ-ONLY; The given assessment's related resources count with skipped state. + SkippedResources *int32 `json:"skippedResources,omitempty"` + // UnsupportedResources - READ-ONLY; The given assessment's related resources count with unsupported state. + UnsupportedResources *int32 `json:"unsupportedResources,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceAssessmentProperties. +func (rcap RegulatoryComplianceAssessmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcap.State != "" { + objectMap["state"] = rcap.State + } + return json.Marshal(objectMap) +} + +// RegulatoryComplianceControl regulatory compliance control details and state +type RegulatoryComplianceControl struct { + autorest.Response `json:"-"` + // RegulatoryComplianceControlProperties - Regulatory compliance control data + *RegulatoryComplianceControlProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceControl. +func (rcc RegulatoryComplianceControl) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcc.RegulatoryComplianceControlProperties != nil { + objectMap["properties"] = rcc.RegulatoryComplianceControlProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegulatoryComplianceControl struct. +func (rcc *RegulatoryComplianceControl) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var regulatoryComplianceControlProperties RegulatoryComplianceControlProperties + err = json.Unmarshal(*v, ®ulatoryComplianceControlProperties) + if err != nil { + return err + } + rcc.RegulatoryComplianceControlProperties = ®ulatoryComplianceControlProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rcc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rcc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rcc.Type = &typeVar + } + } + } + + return nil +} + +// RegulatoryComplianceControlList list of regulatory compliance controls response +type RegulatoryComplianceControlList struct { + autorest.Response `json:"-"` + // Value - List of regulatory compliance controls + Value *[]RegulatoryComplianceControl `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceControlList. +func (rccl RegulatoryComplianceControlList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rccl.Value != nil { + objectMap["value"] = rccl.Value + } + return json.Marshal(objectMap) +} + +// RegulatoryComplianceControlListIterator provides access to a complete listing of RegulatoryComplianceControl +// values. +type RegulatoryComplianceControlListIterator struct { + i int + page RegulatoryComplianceControlListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RegulatoryComplianceControlListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RegulatoryComplianceControlListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegulatoryComplianceControlListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RegulatoryComplianceControlListIterator) Response() RegulatoryComplianceControlList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RegulatoryComplianceControlListIterator) Value() RegulatoryComplianceControl { + if !iter.page.NotDone() { + return RegulatoryComplianceControl{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegulatoryComplianceControlListIterator type. +func NewRegulatoryComplianceControlListIterator(page RegulatoryComplianceControlListPage) RegulatoryComplianceControlListIterator { + return RegulatoryComplianceControlListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rccl RegulatoryComplianceControlList) IsEmpty() bool { + return rccl.Value == nil || len(*rccl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rccl RegulatoryComplianceControlList) hasNextLink() bool { + return rccl.NextLink != nil && len(*rccl.NextLink) != 0 +} + +// regulatoryComplianceControlListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rccl RegulatoryComplianceControlList) regulatoryComplianceControlListPreparer(ctx context.Context) (*http.Request, error) { + if !rccl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rccl.NextLink))) +} + +// RegulatoryComplianceControlListPage contains a page of RegulatoryComplianceControl values. +type RegulatoryComplianceControlListPage struct { + fn func(context.Context, RegulatoryComplianceControlList) (RegulatoryComplianceControlList, error) + rccl RegulatoryComplianceControlList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RegulatoryComplianceControlListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rccl) + if err != nil { + return err + } + page.rccl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegulatoryComplianceControlListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegulatoryComplianceControlListPage) NotDone() bool { + return !page.rccl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegulatoryComplianceControlListPage) Response() RegulatoryComplianceControlList { + return page.rccl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegulatoryComplianceControlListPage) Values() []RegulatoryComplianceControl { + if page.rccl.IsEmpty() { + return nil + } + return *page.rccl.Value +} + +// Creates a new instance of the RegulatoryComplianceControlListPage type. +func NewRegulatoryComplianceControlListPage(getNextPage func(context.Context, RegulatoryComplianceControlList) (RegulatoryComplianceControlList, error)) RegulatoryComplianceControlListPage { + return RegulatoryComplianceControlListPage{fn: getNextPage} +} + +// RegulatoryComplianceControlProperties regulatory compliance control data +type RegulatoryComplianceControlProperties struct { + // Description - READ-ONLY; The description of the regulatory compliance control + Description *string `json:"description,omitempty"` + // State - Aggregative state based on the control's supported assessments states. Possible values include: 'StatePassed', 'StateFailed', 'StateSkipped', 'StateUnsupported' + State State `json:"state,omitempty"` + // PassedAssessments - READ-ONLY; The number of supported regulatory compliance assessments of the given control with a passed state + PassedAssessments *int32 `json:"passedAssessments,omitempty"` + // FailedAssessments - READ-ONLY; The number of supported regulatory compliance assessments of the given control with a failed state + FailedAssessments *int32 `json:"failedAssessments,omitempty"` + // SkippedAssessments - READ-ONLY; The number of supported regulatory compliance assessments of the given control with a skipped state + SkippedAssessments *int32 `json:"skippedAssessments,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceControlProperties. +func (rccp RegulatoryComplianceControlProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rccp.State != "" { + objectMap["state"] = rccp.State + } + return json.Marshal(objectMap) +} + +// RegulatoryComplianceStandard regulatory compliance standard details and state +type RegulatoryComplianceStandard struct { + autorest.Response `json:"-"` + // RegulatoryComplianceStandardProperties - Regulatory compliance standard data + *RegulatoryComplianceStandardProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceStandard. +func (rcs RegulatoryComplianceStandard) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcs.RegulatoryComplianceStandardProperties != nil { + objectMap["properties"] = rcs.RegulatoryComplianceStandardProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RegulatoryComplianceStandard struct. +func (rcs *RegulatoryComplianceStandard) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var regulatoryComplianceStandardProperties RegulatoryComplianceStandardProperties + err = json.Unmarshal(*v, ®ulatoryComplianceStandardProperties) + if err != nil { + return err + } + rcs.RegulatoryComplianceStandardProperties = ®ulatoryComplianceStandardProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rcs.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rcs.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rcs.Type = &typeVar + } + } + } + + return nil +} + +// RegulatoryComplianceStandardList list of regulatory compliance standards response +type RegulatoryComplianceStandardList struct { + autorest.Response `json:"-"` + Value *[]RegulatoryComplianceStandard `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceStandardList. +func (rcsl RegulatoryComplianceStandardList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcsl.Value != nil { + objectMap["value"] = rcsl.Value + } + return json.Marshal(objectMap) +} + +// RegulatoryComplianceStandardListIterator provides access to a complete listing of +// RegulatoryComplianceStandard values. +type RegulatoryComplianceStandardListIterator struct { + i int + page RegulatoryComplianceStandardListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RegulatoryComplianceStandardListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RegulatoryComplianceStandardListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RegulatoryComplianceStandardListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RegulatoryComplianceStandardListIterator) Response() RegulatoryComplianceStandardList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RegulatoryComplianceStandardListIterator) Value() RegulatoryComplianceStandard { + if !iter.page.NotDone() { + return RegulatoryComplianceStandard{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RegulatoryComplianceStandardListIterator type. +func NewRegulatoryComplianceStandardListIterator(page RegulatoryComplianceStandardListPage) RegulatoryComplianceStandardListIterator { + return RegulatoryComplianceStandardListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rcsl RegulatoryComplianceStandardList) IsEmpty() bool { + return rcsl.Value == nil || len(*rcsl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rcsl RegulatoryComplianceStandardList) hasNextLink() bool { + return rcsl.NextLink != nil && len(*rcsl.NextLink) != 0 +} + +// regulatoryComplianceStandardListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rcsl RegulatoryComplianceStandardList) regulatoryComplianceStandardListPreparer(ctx context.Context) (*http.Request, error) { + if !rcsl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rcsl.NextLink))) +} + +// RegulatoryComplianceStandardListPage contains a page of RegulatoryComplianceStandard values. +type RegulatoryComplianceStandardListPage struct { + fn func(context.Context, RegulatoryComplianceStandardList) (RegulatoryComplianceStandardList, error) + rcsl RegulatoryComplianceStandardList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RegulatoryComplianceStandardListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rcsl) + if err != nil { + return err + } + page.rcsl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RegulatoryComplianceStandardListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RegulatoryComplianceStandardListPage) NotDone() bool { + return !page.rcsl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RegulatoryComplianceStandardListPage) Response() RegulatoryComplianceStandardList { + return page.rcsl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RegulatoryComplianceStandardListPage) Values() []RegulatoryComplianceStandard { + if page.rcsl.IsEmpty() { + return nil + } + return *page.rcsl.Value +} + +// Creates a new instance of the RegulatoryComplianceStandardListPage type. +func NewRegulatoryComplianceStandardListPage(getNextPage func(context.Context, RegulatoryComplianceStandardList) (RegulatoryComplianceStandardList, error)) RegulatoryComplianceStandardListPage { + return RegulatoryComplianceStandardListPage{fn: getNextPage} +} + +// RegulatoryComplianceStandardProperties regulatory compliance standard data +type RegulatoryComplianceStandardProperties struct { + // State - Aggregative state based on the standard's supported controls states. Possible values include: 'StatePassed', 'StateFailed', 'StateSkipped', 'StateUnsupported' + State State `json:"state,omitempty"` + // PassedControls - READ-ONLY; The number of supported regulatory compliance controls of the given standard with a passed state + PassedControls *int32 `json:"passedControls,omitempty"` + // FailedControls - READ-ONLY; The number of supported regulatory compliance controls of the given standard with a failed state + FailedControls *int32 `json:"failedControls,omitempty"` + // SkippedControls - READ-ONLY; The number of supported regulatory compliance controls of the given standard with a skipped state + SkippedControls *int32 `json:"skippedControls,omitempty"` + // UnsupportedControls - READ-ONLY; The number of regulatory compliance controls of the given standard which are unsupported by automated assessments + UnsupportedControls *int32 `json:"unsupportedControls,omitempty"` +} + +// MarshalJSON is the custom marshaler for RegulatoryComplianceStandardProperties. +func (rcsp RegulatoryComplianceStandardProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcsp.State != "" { + objectMap["state"] = rcsp.State + } + return json.Marshal(objectMap) +} + +// Resource describes an Azure resource. +type Resource struct { + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// BasicResourceDetails details of the resource that was assessed +type BasicResourceDetails interface { + AsOnPremiseSQLResourceDetails() (*OnPremiseSQLResourceDetails, bool) + AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) + AsBasicOnPremiseResourceDetails() (BasicOnPremiseResourceDetails, bool) + AsAzureResourceDetails() (*AzureResourceDetails, bool) + AsResourceDetails() (*ResourceDetails, bool) +} + +// ResourceDetails details of the resource that was assessed +type ResourceDetails struct { + // Source - Possible values include: 'SourceResourceDetails', 'SourceOnPremiseSQL', 'SourceOnPremise', 'SourceAzure' + Source Source `json:"source,omitempty"` +} + +func unmarshalBasicResourceDetails(body []byte) (BasicResourceDetails, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["source"] { + case string(SourceOnPremiseSQL): + var opsrd OnPremiseSQLResourceDetails + err := json.Unmarshal(body, &opsrd) + return opsrd, err + case string(SourceOnPremise): + var oprd OnPremiseResourceDetails + err := json.Unmarshal(body, &oprd) + return oprd, err + case string(SourceAzure): + var ard AzureResourceDetails + err := json.Unmarshal(body, &ard) + return ard, err + default: + var rd ResourceDetails + err := json.Unmarshal(body, &rd) + return rd, err + } +} +func unmarshalBasicResourceDetailsArray(body []byte) ([]BasicResourceDetails, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + rdArray := make([]BasicResourceDetails, len(rawMessages)) + + for index, rawMessage := range rawMessages { + rd, err := unmarshalBasicResourceDetails(*rawMessage) + if err != nil { + return nil, err + } + rdArray[index] = rd + } + return rdArray, nil +} + +// MarshalJSON is the custom marshaler for ResourceDetails. +func (rd ResourceDetails) MarshalJSON() ([]byte, error) { + rd.Source = SourceResourceDetails + objectMap := make(map[string]interface{}) + if rd.Source != "" { + objectMap["source"] = rd.Source + } + return json.Marshal(objectMap) +} + +// AsOnPremiseSQLResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsOnPremiseSQLResourceDetails() (*OnPremiseSQLResourceDetails, bool) { + return nil, false +} + +// AsOnPremiseResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsOnPremiseResourceDetails() (*OnPremiseResourceDetails, bool) { + return nil, false +} + +// AsBasicOnPremiseResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsBasicOnPremiseResourceDetails() (BasicOnPremiseResourceDetails, bool) { + return nil, false +} + +// AsAzureResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsAzureResourceDetails() (*AzureResourceDetails, bool) { + return nil, false +} + +// AsResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsResourceDetails() (*ResourceDetails, bool) { + return &rd, true +} + +// AsBasicResourceDetails is the BasicResourceDetails implementation for ResourceDetails. +func (rd ResourceDetails) AsBasicResourceDetails() (BasicResourceDetails, bool) { + return &rd, true +} + +// Rule describes remote addresses that is recommended to communicate with the Azure resource on some +// (Protocol, Port, Direction). All other remote addresses are recommended to be blocked +type Rule struct { + // Name - The name of the rule + Name *string `json:"name,omitempty"` + // Direction - The rule's direction. Possible values include: 'Inbound', 'Outbound' + Direction Direction `json:"direction,omitempty"` + // DestinationPort - The rule's destination port + DestinationPort *int32 `json:"destinationPort,omitempty"` + // Protocols - The rule's transport protocols + Protocols *[]TransportProtocol `json:"protocols,omitempty"` + // IPAddresses - The remote IP addresses that should be able to communicate with the Azure resource on the rule's destination port and protocol + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} + +// ScopeElement a more specific scope used to identify the alerts to suppress. +type ScopeElement struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Field - The alert entity type to suppress by. + Field *string `json:"field,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScopeElement. +func (se ScopeElement) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if se.Field != nil { + objectMap["field"] = se.Field + } + for k, v := range se.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScopeElement struct. +func (se *ScopeElement) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if se.AdditionalProperties == nil { + se.AdditionalProperties = make(map[string]interface{}) + } + se.AdditionalProperties[k] = additionalProperties + } + case "field": + if v != nil { + var field string + err = json.Unmarshal(*v, &field) + if err != nil { + return err + } + se.Field = &field + } + } + } + + return nil +} + +// ScoreDetails calculation result data +type ScoreDetails struct { + // Max - READ-ONLY; Maximum score available + Max *int32 `json:"max,omitempty"` + // Current - READ-ONLY; Current score + Current *float64 `json:"current,omitempty"` +} + +// SecureScoreControlDefinitionItem information about the security control. +type SecureScoreControlDefinitionItem struct { + *SecureScoreControlDefinitionItemProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecureScoreControlDefinitionItem. +func (sscdi SecureScoreControlDefinitionItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sscdi.SecureScoreControlDefinitionItemProperties != nil { + objectMap["properties"] = sscdi.SecureScoreControlDefinitionItemProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SecureScoreControlDefinitionItem struct. +func (sscdi *SecureScoreControlDefinitionItem) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var secureScoreControlDefinitionItemProperties SecureScoreControlDefinitionItemProperties + err = json.Unmarshal(*v, &secureScoreControlDefinitionItemProperties) + if err != nil { + return err + } + sscdi.SecureScoreControlDefinitionItemProperties = &secureScoreControlDefinitionItemProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sscdi.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sscdi.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sscdi.Type = &typeVar + } + } + } + + return nil +} + +// SecureScoreControlDefinitionItemProperties security Control Definition Properties. +type SecureScoreControlDefinitionItemProperties struct { + // DisplayName - READ-ONLY; User friendly display name of the control + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; User friendly description of the control + Description *string `json:"description,omitempty"` + // MaxScore - READ-ONLY; Maximum control score (0..10) + MaxScore *int32 `json:"maxScore,omitempty"` + // Source - READ-ONLY; Source object from which the control was created + Source *SecureScoreControlDefinitionSource `json:"source,omitempty"` + // AssessmentDefinitions - READ-ONLY; Array of assessments metadata IDs that are included in this security control + AssessmentDefinitions *[]AzureResourceLink `json:"assessmentDefinitions,omitempty"` +} + +// SecureScoreControlDefinitionList list of security controls definition +type SecureScoreControlDefinitionList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Collection of security controls definition in this page + Value *[]SecureScoreControlDefinitionItem `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// SecureScoreControlDefinitionListIterator provides access to a complete listing of +// SecureScoreControlDefinitionItem values. +type SecureScoreControlDefinitionListIterator struct { + i int + page SecureScoreControlDefinitionListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SecureScoreControlDefinitionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlDefinitionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SecureScoreControlDefinitionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SecureScoreControlDefinitionListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SecureScoreControlDefinitionListIterator) Response() SecureScoreControlDefinitionList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SecureScoreControlDefinitionListIterator) Value() SecureScoreControlDefinitionItem { + if !iter.page.NotDone() { + return SecureScoreControlDefinitionItem{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SecureScoreControlDefinitionListIterator type. +func NewSecureScoreControlDefinitionListIterator(page SecureScoreControlDefinitionListPage) SecureScoreControlDefinitionListIterator { + return SecureScoreControlDefinitionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sscdl SecureScoreControlDefinitionList) IsEmpty() bool { + return sscdl.Value == nil || len(*sscdl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sscdl SecureScoreControlDefinitionList) hasNextLink() bool { + return sscdl.NextLink != nil && len(*sscdl.NextLink) != 0 +} + +// secureScoreControlDefinitionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sscdl SecureScoreControlDefinitionList) secureScoreControlDefinitionListPreparer(ctx context.Context) (*http.Request, error) { + if !sscdl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sscdl.NextLink))) +} + +// SecureScoreControlDefinitionListPage contains a page of SecureScoreControlDefinitionItem values. +type SecureScoreControlDefinitionListPage struct { + fn func(context.Context, SecureScoreControlDefinitionList) (SecureScoreControlDefinitionList, error) + sscdl SecureScoreControlDefinitionList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SecureScoreControlDefinitionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlDefinitionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sscdl) + if err != nil { + return err + } + page.sscdl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SecureScoreControlDefinitionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SecureScoreControlDefinitionListPage) NotDone() bool { + return !page.sscdl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SecureScoreControlDefinitionListPage) Response() SecureScoreControlDefinitionList { + return page.sscdl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SecureScoreControlDefinitionListPage) Values() []SecureScoreControlDefinitionItem { + if page.sscdl.IsEmpty() { + return nil + } + return *page.sscdl.Value +} + +// Creates a new instance of the SecureScoreControlDefinitionListPage type. +func NewSecureScoreControlDefinitionListPage(getNextPage func(context.Context, SecureScoreControlDefinitionList) (SecureScoreControlDefinitionList, error)) SecureScoreControlDefinitionListPage { + return SecureScoreControlDefinitionListPage{fn: getNextPage} +} + +// SecureScoreControlDefinitionSource the type of the security control (For example, BuiltIn) +type SecureScoreControlDefinitionSource struct { + // SourceType - The type of security control (for example, BuiltIn). Possible values include: 'ControlTypeBuiltIn', 'ControlTypeCustom' + SourceType ControlType `json:"sourceType,omitempty"` +} + +// SecureScoreControlDetails details of the security control, its score, and the health status of the relevant +// resources. +type SecureScoreControlDetails struct { + *SecureScoreControlScoreDetails `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecureScoreControlDetails. +func (sscd SecureScoreControlDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sscd.SecureScoreControlScoreDetails != nil { + objectMap["properties"] = sscd.SecureScoreControlScoreDetails + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SecureScoreControlDetails struct. +func (sscd *SecureScoreControlDetails) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var secureScoreControlScoreDetails SecureScoreControlScoreDetails + err = json.Unmarshal(*v, &secureScoreControlScoreDetails) + if err != nil { + return err + } + sscd.SecureScoreControlScoreDetails = &secureScoreControlScoreDetails + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sscd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sscd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sscd.Type = &typeVar + } + } + } + + return nil +} + +// SecureScoreControlList list of security controls +type SecureScoreControlList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Collection of security controls in this page + Value *[]SecureScoreControlDetails `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// SecureScoreControlListIterator provides access to a complete listing of SecureScoreControlDetails values. +type SecureScoreControlListIterator struct { + i int + page SecureScoreControlListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SecureScoreControlListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SecureScoreControlListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SecureScoreControlListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SecureScoreControlListIterator) Response() SecureScoreControlList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SecureScoreControlListIterator) Value() SecureScoreControlDetails { + if !iter.page.NotDone() { + return SecureScoreControlDetails{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SecureScoreControlListIterator type. +func NewSecureScoreControlListIterator(page SecureScoreControlListPage) SecureScoreControlListIterator { + return SecureScoreControlListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sscl SecureScoreControlList) IsEmpty() bool { + return sscl.Value == nil || len(*sscl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sscl SecureScoreControlList) hasNextLink() bool { + return sscl.NextLink != nil && len(*sscl.NextLink) != 0 +} + +// secureScoreControlListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sscl SecureScoreControlList) secureScoreControlListPreparer(ctx context.Context) (*http.Request, error) { + if !sscl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sscl.NextLink))) +} + +// SecureScoreControlListPage contains a page of SecureScoreControlDetails values. +type SecureScoreControlListPage struct { + fn func(context.Context, SecureScoreControlList) (SecureScoreControlList, error) + sscl SecureScoreControlList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SecureScoreControlListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sscl) + if err != nil { + return err + } + page.sscl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SecureScoreControlListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SecureScoreControlListPage) NotDone() bool { + return !page.sscl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SecureScoreControlListPage) Response() SecureScoreControlList { + return page.sscl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SecureScoreControlListPage) Values() []SecureScoreControlDetails { + if page.sscl.IsEmpty() { + return nil + } + return *page.sscl.Value +} + +// Creates a new instance of the SecureScoreControlListPage type. +func NewSecureScoreControlListPage(getNextPage func(context.Context, SecureScoreControlList) (SecureScoreControlList, error)) SecureScoreControlListPage { + return SecureScoreControlListPage{fn: getNextPage} +} + +// SecureScoreControlScore calculation result data +type SecureScoreControlScore struct { + // Max - READ-ONLY; Maximum control score (0..10) + Max *int32 `json:"max,omitempty"` + // Current - READ-ONLY; Actual score for the control = (achieved points / total points) * max score. if total points is zeroed, the return number is 0.00 + Current *float64 `json:"current,omitempty"` +} + +// SecureScoreControlScoreDetails calculation result data in control level +type SecureScoreControlScoreDetails struct { + // DisplayName - READ-ONLY; User friendly display name of the control + DisplayName *string `json:"displayName,omitempty"` + // ScoreDetails - Actual score object for the control + *ScoreDetails `json:"score,omitempty"` + // HealthyResourceCount - READ-ONLY; Number of healthy resources in the control + HealthyResourceCount *int32 `json:"healthyResourceCount,omitempty"` + // UnhealthyResourceCount - READ-ONLY; Number of unhealthy resources in the control + UnhealthyResourceCount *int32 `json:"unhealthyResourceCount,omitempty"` + // NotApplicableResourceCount - READ-ONLY; Number of not applicable resources in the control + NotApplicableResourceCount *int32 `json:"notApplicableResourceCount,omitempty"` + Definition *SecureScoreControlDefinitionItem `json:"definition,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecureScoreControlScoreDetails. +func (sscsd SecureScoreControlScoreDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sscsd.ScoreDetails != nil { + objectMap["score"] = sscsd.ScoreDetails + } + if sscsd.Definition != nil { + objectMap["definition"] = sscsd.Definition + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SecureScoreControlScoreDetails struct. +func (sscsd *SecureScoreControlScoreDetails) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + sscsd.DisplayName = &displayName + } + case "score": + if v != nil { + var scoreDetails ScoreDetails + err = json.Unmarshal(*v, &scoreDetails) + if err != nil { + return err + } + sscsd.ScoreDetails = &scoreDetails + } + case "healthyResourceCount": + if v != nil { + var healthyResourceCount int32 + err = json.Unmarshal(*v, &healthyResourceCount) + if err != nil { + return err + } + sscsd.HealthyResourceCount = &healthyResourceCount + } + case "unhealthyResourceCount": + if v != nil { + var unhealthyResourceCount int32 + err = json.Unmarshal(*v, &unhealthyResourceCount) + if err != nil { + return err + } + sscsd.UnhealthyResourceCount = &unhealthyResourceCount + } + case "notApplicableResourceCount": + if v != nil { + var notApplicableResourceCount int32 + err = json.Unmarshal(*v, ¬ApplicableResourceCount) + if err != nil { + return err + } + sscsd.NotApplicableResourceCount = ¬ApplicableResourceCount + } + case "definition": + if v != nil { + var definition SecureScoreControlDefinitionItem + err = json.Unmarshal(*v, &definition) + if err != nil { + return err + } + sscsd.Definition = &definition + } + } + } + + return nil +} + +// SecureScoreItem secure score item data model +type SecureScoreItem struct { + autorest.Response `json:"-"` + // SecureScoreItemProperties - READ-ONLY; Secure score item + *SecureScoreItemProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecureScoreItem. +func (ssi SecureScoreItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SecureScoreItem struct. +func (ssi *SecureScoreItem) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var secureScoreItemProperties SecureScoreItemProperties + err = json.Unmarshal(*v, &secureScoreItemProperties) + if err != nil { + return err + } + ssi.SecureScoreItemProperties = &secureScoreItemProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ssi.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ssi.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ssi.Type = &typeVar + } + } + } + + return nil +} + +// SecureScoreItemProperties describes properties of a calculated secure score. +type SecureScoreItemProperties struct { + // DisplayName - READ-ONLY; The initiative’s name + DisplayName *string `json:"displayName,omitempty"` + // ScoreDetails - READ-ONLY; score object + *ScoreDetails `json:"score,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecureScoreItemProperties. +func (ssip SecureScoreItemProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SecureScoreItemProperties struct. +func (ssip *SecureScoreItemProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + ssip.DisplayName = &displayName + } + case "score": + if v != nil { + var scoreDetails ScoreDetails + err = json.Unmarshal(*v, &scoreDetails) + if err != nil { + return err + } + ssip.ScoreDetails = &scoreDetails + } + } + } + + return nil +} + +// SecureScoresList list of secure scores +type SecureScoresList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Collection of secure scores in this page + Value *[]SecureScoreItem `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// SecureScoresListIterator provides access to a complete listing of SecureScoreItem values. +type SecureScoresListIterator struct { + i int + page SecureScoresListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SecureScoresListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoresListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SecureScoresListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SecureScoresListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SecureScoresListIterator) Response() SecureScoresList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SecureScoresListIterator) Value() SecureScoreItem { + if !iter.page.NotDone() { + return SecureScoreItem{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SecureScoresListIterator type. +func NewSecureScoresListIterator(page SecureScoresListPage) SecureScoresListIterator { + return SecureScoresListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ssl SecureScoresList) IsEmpty() bool { + return ssl.Value == nil || len(*ssl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ssl SecureScoresList) hasNextLink() bool { + return ssl.NextLink != nil && len(*ssl.NextLink) != 0 +} + +// secureScoresListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ssl SecureScoresList) secureScoresListPreparer(ctx context.Context) (*http.Request, error) { + if !ssl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ssl.NextLink))) +} + +// SecureScoresListPage contains a page of SecureScoreItem values. +type SecureScoresListPage struct { + fn func(context.Context, SecureScoresList) (SecureScoresList, error) + ssl SecureScoresList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SecureScoresListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoresListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ssl) + if err != nil { + return err + } + page.ssl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SecureScoresListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SecureScoresListPage) NotDone() bool { + return !page.ssl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SecureScoresListPage) Response() SecureScoresList { + return page.ssl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SecureScoresListPage) Values() []SecureScoreItem { + if page.ssl.IsEmpty() { + return nil + } + return *page.ssl.Value +} + +// Creates a new instance of the SecureScoresListPage type. +func NewSecureScoresListPage(getNextPage func(context.Context, SecureScoresList) (SecureScoresList, error)) SecureScoresListPage { + return SecureScoresListPage{fn: getNextPage} +} + +// SensitivityLabel the sensitivity label. +type SensitivityLabel struct { + // DisplayName - The name of the sensitivity label. + DisplayName *string `json:"displayName,omitempty"` + // Description - The description of the sensitivity label. + Description *string `json:"description,omitempty"` + // Rank - The rank of the sensitivity label. Possible values include: 'RankNone', 'RankLow', 'RankMedium', 'RankHigh', 'RankCritical' + Rank Rank `json:"rank,omitempty"` + // Order - The order of the sensitivity label. + Order *int32 `json:"order,omitempty"` + // Enabled - Indicates whether the label is enabled or not. + Enabled *bool `json:"enabled,omitempty"` +} + +// ServerVulnerabilityAssessment describes the server vulnerability assessment details on a resource +type ServerVulnerabilityAssessment struct { + autorest.Response `json:"-"` + *ServerVulnerabilityAssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVulnerabilityAssessment. +func (sva ServerVulnerabilityAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sva.ServerVulnerabilityAssessmentProperties != nil { + objectMap["properties"] = sva.ServerVulnerabilityAssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerVulnerabilityAssessment struct. +func (sva *ServerVulnerabilityAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverVulnerabilityAssessmentProperties ServerVulnerabilityAssessmentProperties + err = json.Unmarshal(*v, &serverVulnerabilityAssessmentProperties) + if err != nil { + return err + } + sva.ServerVulnerabilityAssessmentProperties = &serverVulnerabilityAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sva.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sva.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sva.Type = &typeVar + } + } + } + + return nil +} + +// ServerVulnerabilityAssessmentProperties describes ServerVulnerabilityAssessment properties. +type ServerVulnerabilityAssessmentProperties struct { + // ProvisioningState - READ-ONLY; The provisioningState of the vulnerability assessment capability on the VM. Possible values include: 'ProvisioningState1Succeeded', 'ProvisioningState1Failed', 'ProvisioningState1Canceled', 'ProvisioningState1Provisioning', 'ProvisioningState1Deprovisioning' + ProvisioningState ProvisioningState1 `json:"provisioningState,omitempty"` +} + +// ServerVulnerabilityAssessmentsList list of server vulnerability assessments +type ServerVulnerabilityAssessmentsList struct { + autorest.Response `json:"-"` + Value *[]ServerVulnerabilityAssessment `json:"value,omitempty"` +} + +// ServerVulnerabilityProperties additional context fields for server vulnerability assessment +type ServerVulnerabilityProperties struct { + // Type - READ-ONLY; Vulnerability Type. e.g: Vulnerability, Potential Vulnerability, Information Gathered + Type *string `json:"type,omitempty"` + // Cvss - READ-ONLY; Dictionary from cvss version to cvss details object + Cvss map[string]*CVSS `json:"cvss"` + // Patchable - READ-ONLY; Indicates whether a patch is available or not + Patchable *bool `json:"patchable,omitempty"` + // Cve - READ-ONLY; List of CVEs + Cve *[]CVE `json:"cve,omitempty"` + // Threat - READ-ONLY; Threat name + Threat *string `json:"threat,omitempty"` + // PublishedTime - READ-ONLY; Published time + PublishedTime *date.Time `json:"publishedTime,omitempty"` + // VendorReferences - READ-ONLY + VendorReferences *[]VendorReference `json:"vendorReferences,omitempty"` + // AssessedResourceType - Possible values include: 'AssessedResourceTypeAdditionalData', 'AssessedResourceTypeSQLServerVulnerability', 'AssessedResourceTypeContainerRegistryVulnerability', 'AssessedResourceTypeServerVulnerabilityAssessment' + AssessedResourceType AssessedResourceType `json:"assessedResourceType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVulnerabilityProperties. +func (svp ServerVulnerabilityProperties) MarshalJSON() ([]byte, error) { + svp.AssessedResourceType = AssessedResourceTypeServerVulnerabilityAssessment + objectMap := make(map[string]interface{}) + if svp.AssessedResourceType != "" { + objectMap["assessedResourceType"] = svp.AssessedResourceType + } + return json.Marshal(objectMap) +} + +// AsSQLServerVulnerabilityProperties is the BasicAdditionalData implementation for ServerVulnerabilityProperties. +func (svp ServerVulnerabilityProperties) AsSQLServerVulnerabilityProperties() (*SQLServerVulnerabilityProperties, bool) { + return nil, false +} + +// AsContainerRegistryVulnerabilityProperties is the BasicAdditionalData implementation for ServerVulnerabilityProperties. +func (svp ServerVulnerabilityProperties) AsContainerRegistryVulnerabilityProperties() (*ContainerRegistryVulnerabilityProperties, bool) { + return nil, false +} + +// AsServerVulnerabilityProperties is the BasicAdditionalData implementation for ServerVulnerabilityProperties. +func (svp ServerVulnerabilityProperties) AsServerVulnerabilityProperties() (*ServerVulnerabilityProperties, bool) { + return &svp, true +} + +// AsAdditionalData is the BasicAdditionalData implementation for ServerVulnerabilityProperties. +func (svp ServerVulnerabilityProperties) AsAdditionalData() (*AdditionalData, bool) { + return nil, false +} + +// AsBasicAdditionalData is the BasicAdditionalData implementation for ServerVulnerabilityProperties. +func (svp ServerVulnerabilityProperties) AsBasicAdditionalData() (BasicAdditionalData, bool) { + return &svp, true +} + +// ServicePrincipalProperties details of the service principal. +type ServicePrincipalProperties struct { + // ApplicationID - Application id of service principal. + ApplicationID *string `json:"applicationId,omitempty"` + // Secret - A secret string that the application uses to prove its identity, also can be referred to as application password (write only). + Secret *string `json:"secret,omitempty"` +} + +// BasicSetting represents a security setting in Azure Security Center. +type BasicSetting interface { + AsDataExportSettings() (*DataExportSettings, bool) + AsSetting() (*Setting, bool) +} + +// Setting represents a security setting in Azure Security Center. +type Setting struct { + autorest.Response `json:"-"` + // Kind - Possible values include: 'KindSettingResource', 'KindSetting', 'KindDataExportSettings' + Kind KindEnum `json:"kind,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +func unmarshalBasicSetting(body []byte) (BasicSetting, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindDataExportSettings): + var desVar DataExportSettings + err := json.Unmarshal(body, &desVar) + return desVar, err + default: + var s Setting + err := json.Unmarshal(body, &s) + return s, err + } +} +func unmarshalBasicSettingArray(body []byte) ([]BasicSetting, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + sArray := make([]BasicSetting, len(rawMessages)) + + for index, rawMessage := range rawMessages { + s, err := unmarshalBasicSetting(*rawMessage) + if err != nil { + return nil, err + } + sArray[index] = s + } + return sArray, nil +} + +// MarshalJSON is the custom marshaler for Setting. +func (s Setting) MarshalJSON() ([]byte, error) { + s.Kind = KindSetting + objectMap := make(map[string]interface{}) + if s.Kind != "" { + objectMap["kind"] = s.Kind + } + return json.Marshal(objectMap) +} + +// AsSetting is the BasicSettingResource implementation for Setting. +func (s Setting) AsSetting() (*Setting, bool) { + return &s, true +} + +// AsBasicSetting is the BasicSettingResource implementation for Setting. +func (s Setting) AsBasicSetting() (BasicSetting, bool) { + return &s, true +} + +// AsDataExportSettings is the BasicSettingResource implementation for Setting. +func (s Setting) AsDataExportSettings() (*DataExportSettings, bool) { + return nil, false +} + +// AsSettingResource is the BasicSettingResource implementation for Setting. +func (s Setting) AsSettingResource() (*SettingResource, bool) { + return nil, false +} + +// AsBasicSettingResource is the BasicSettingResource implementation for Setting. +func (s Setting) AsBasicSettingResource() (BasicSettingResource, bool) { + return &s, true +} + +// BasicSettingResource the kind of the security setting +type BasicSettingResource interface { + AsSetting() (*Setting, bool) + AsBasicSetting() (BasicSetting, bool) + AsDataExportSettings() (*DataExportSettings, bool) + AsSettingResource() (*SettingResource, bool) +} + +// SettingResource the kind of the security setting +type SettingResource struct { + // Kind - Possible values include: 'KindSettingResource', 'KindSetting', 'KindDataExportSettings' + Kind KindEnum `json:"kind,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +func unmarshalBasicSettingResource(body []byte) (BasicSettingResource, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindSetting): + var s Setting + err := json.Unmarshal(body, &s) + return s, err + case string(KindDataExportSettings): + var desVar DataExportSettings + err := json.Unmarshal(body, &desVar) + return desVar, err + default: + var sr SettingResource + err := json.Unmarshal(body, &sr) + return sr, err + } +} +func unmarshalBasicSettingResourceArray(body []byte) ([]BasicSettingResource, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + srArray := make([]BasicSettingResource, len(rawMessages)) + + for index, rawMessage := range rawMessages { + sr, err := unmarshalBasicSettingResource(*rawMessage) + if err != nil { + return nil, err + } + srArray[index] = sr + } + return srArray, nil +} + +// MarshalJSON is the custom marshaler for SettingResource. +func (sr SettingResource) MarshalJSON() ([]byte, error) { + sr.Kind = KindSettingResource + objectMap := make(map[string]interface{}) + if sr.Kind != "" { + objectMap["kind"] = sr.Kind + } + return json.Marshal(objectMap) +} + +// AsSetting is the BasicSettingResource implementation for SettingResource. +func (sr SettingResource) AsSetting() (*Setting, bool) { + return nil, false +} + +// AsBasicSetting is the BasicSettingResource implementation for SettingResource. +func (sr SettingResource) AsBasicSetting() (BasicSetting, bool) { + return nil, false +} + +// AsDataExportSettings is the BasicSettingResource implementation for SettingResource. +func (sr SettingResource) AsDataExportSettings() (*DataExportSettings, bool) { + return nil, false +} + +// AsSettingResource is the BasicSettingResource implementation for SettingResource. +func (sr SettingResource) AsSettingResource() (*SettingResource, bool) { + return &sr, true +} + +// AsBasicSettingResource is the BasicSettingResource implementation for SettingResource. +func (sr SettingResource) AsBasicSettingResource() (BasicSettingResource, bool) { + return &sr, true +} + +// SettingsList subscription settings list. +type SettingsList struct { + autorest.Response `json:"-"` + // Value - The settings list. + Value *[]BasicSetting `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SettingsList. +func (sl SettingsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sl.Value != nil { + objectMap["value"] = sl.Value + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SettingsList struct. +func (sl *SettingsList) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "value": + if v != nil { + value, err := unmarshalBasicSettingArray(*v) + if err != nil { + return err + } + sl.Value = &value + } + case "nextLink": + if v != nil { + var nextLink string + err = json.Unmarshal(*v, &nextLink) + if err != nil { + return err + } + sl.NextLink = &nextLink + } + } + } + + return nil +} + +// SettingsListIterator provides access to a complete listing of Setting values. +type SettingsListIterator struct { + i int + page SettingsListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SettingsListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SettingsListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SettingsListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SettingsListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SettingsListIterator) Response() SettingsList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SettingsListIterator) Value() BasicSetting { + if !iter.page.NotDone() { + return Setting{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SettingsListIterator type. +func NewSettingsListIterator(page SettingsListPage) SettingsListIterator { + return SettingsListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sl SettingsList) IsEmpty() bool { + return sl.Value == nil || len(*sl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sl SettingsList) hasNextLink() bool { + return sl.NextLink != nil && len(*sl.NextLink) != 0 +} + +// settingsListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sl SettingsList) settingsListPreparer(ctx context.Context) (*http.Request, error) { + if !sl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sl.NextLink))) +} + +// SettingsListPage contains a page of BasicSetting values. +type SettingsListPage struct { + fn func(context.Context, SettingsList) (SettingsList, error) + sl SettingsList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SettingsListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SettingsListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sl) + if err != nil { + return err + } + page.sl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SettingsListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SettingsListPage) NotDone() bool { + return !page.sl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SettingsListPage) Response() SettingsList { + return page.sl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SettingsListPage) Values() []BasicSetting { + if page.sl.IsEmpty() { + return nil + } + return *page.sl.Value +} + +// Creates a new instance of the SettingsListPage type. +func NewSettingsListPage(getNextPage func(context.Context, SettingsList) (SettingsList, error)) SettingsListPage { + return SettingsListPage{fn: getNextPage} +} + +// Solution ... +type Solution struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + *SolutionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Solution. +func (s Solution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.SolutionProperties != nil { + objectMap["properties"] = s.SolutionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Solution struct. +func (s *Solution) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + case "properties": + if v != nil { + var solutionProperties SolutionProperties + err = json.Unmarshal(*v, &solutionProperties) + if err != nil { + return err + } + s.SolutionProperties = &solutionProperties + } + } + } + + return nil +} + +// SolutionList ... +type SolutionList struct { + autorest.Response `json:"-"` + Value *[]Solution `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SolutionList. +func (sl SolutionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sl.Value != nil { + objectMap["value"] = sl.Value + } + return json.Marshal(objectMap) +} + +// SolutionListIterator provides access to a complete listing of Solution values. +type SolutionListIterator struct { + i int + page SolutionListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SolutionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SolutionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SolutionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SolutionListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SolutionListIterator) Response() SolutionList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SolutionListIterator) Value() Solution { + if !iter.page.NotDone() { + return Solution{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SolutionListIterator type. +func NewSolutionListIterator(page SolutionListPage) SolutionListIterator { + return SolutionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sl SolutionList) IsEmpty() bool { + return sl.Value == nil || len(*sl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sl SolutionList) hasNextLink() bool { + return sl.NextLink != nil && len(*sl.NextLink) != 0 +} + +// solutionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sl SolutionList) solutionListPreparer(ctx context.Context) (*http.Request, error) { + if !sl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sl.NextLink))) +} + +// SolutionListPage contains a page of Solution values. +type SolutionListPage struct { + fn func(context.Context, SolutionList) (SolutionList, error) + sl SolutionList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SolutionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SolutionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sl) + if err != nil { + return err + } + page.sl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SolutionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SolutionListPage) NotDone() bool { + return !page.sl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SolutionListPage) Response() SolutionList { + return page.sl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SolutionListPage) Values() []Solution { + if page.sl.IsEmpty() { + return nil + } + return *page.sl.Value +} + +// Creates a new instance of the SolutionListPage type. +func NewSolutionListPage(getNextPage func(context.Context, SolutionList) (SolutionList, error)) SolutionListPage { + return SolutionListPage{fn: getNextPage} +} + +// SolutionProperties ... +type SolutionProperties struct { + // SecurityFamily - The security family of the security solution. Possible values include: 'Waf', 'Ngfw', 'SaasWaf', 'Va' + SecurityFamily Family `json:"securityFamily,omitempty"` + // ProvisioningState - The security family provisioning State. Possible values include: 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateUpdating' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Template - The security solutions' template + Template *string `json:"template,omitempty"` + // ProtectionStatus - The security solutions' status + ProtectionStatus *string `json:"protectionStatus,omitempty"` +} + +// SolutionsReferenceData ... +type SolutionsReferenceData struct { + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + *SolutionsReferenceDataProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SolutionsReferenceData. +func (srd SolutionsReferenceData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if srd.SolutionsReferenceDataProperties != nil { + objectMap["properties"] = srd.SolutionsReferenceDataProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SolutionsReferenceData struct. +func (srd *SolutionsReferenceData) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + srd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + srd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + srd.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + srd.Location = &location + } + case "properties": + if v != nil { + var solutionsReferenceDataProperties SolutionsReferenceDataProperties + err = json.Unmarshal(*v, &solutionsReferenceDataProperties) + if err != nil { + return err + } + srd.SolutionsReferenceDataProperties = &solutionsReferenceDataProperties + } + } + } + + return nil +} + +// SolutionsReferenceDataList ... +type SolutionsReferenceDataList struct { + autorest.Response `json:"-"` + Value *[]SolutionsReferenceData `json:"value,omitempty"` +} + +// SolutionsReferenceDataProperties ... +type SolutionsReferenceDataProperties struct { + // SecurityFamily - The security family of the security solution. Possible values include: 'Waf', 'Ngfw', 'SaasWaf', 'Va' + SecurityFamily Family `json:"securityFamily,omitempty"` + // AlertVendorName - The security solutions' vendor name + AlertVendorName *string `json:"alertVendorName,omitempty"` + // PackageInfoURL - The security solutions' package info url + PackageInfoURL *string `json:"packageInfoUrl,omitempty"` + // ProductName - The security solutions' product name + ProductName *string `json:"productName,omitempty"` + // Publisher - The security solutions' publisher + Publisher *string `json:"publisher,omitempty"` + // PublisherDisplayName - The security solutions' publisher display name + PublisherDisplayName *string `json:"publisherDisplayName,omitempty"` + // Template - The security solutions' template + Template *string `json:"template,omitempty"` +} + +// SQLServerVulnerabilityProperties details of the resource that was assessed +type SQLServerVulnerabilityProperties struct { + // Type - READ-ONLY; The resource type the sub assessment refers to in its resource details + Type *string `json:"type,omitempty"` + // Query - READ-ONLY; The T-SQL query that runs on your SQL database to perform the particular check + Query *string `json:"query,omitempty"` + // AssessedResourceType - Possible values include: 'AssessedResourceTypeAdditionalData', 'AssessedResourceTypeSQLServerVulnerability', 'AssessedResourceTypeContainerRegistryVulnerability', 'AssessedResourceTypeServerVulnerabilityAssessment' + AssessedResourceType AssessedResourceType `json:"assessedResourceType,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLServerVulnerabilityProperties. +func (ssvp SQLServerVulnerabilityProperties) MarshalJSON() ([]byte, error) { + ssvp.AssessedResourceType = AssessedResourceTypeSQLServerVulnerability + objectMap := make(map[string]interface{}) + if ssvp.AssessedResourceType != "" { + objectMap["assessedResourceType"] = ssvp.AssessedResourceType + } + return json.Marshal(objectMap) +} + +// AsSQLServerVulnerabilityProperties is the BasicAdditionalData implementation for SQLServerVulnerabilityProperties. +func (ssvp SQLServerVulnerabilityProperties) AsSQLServerVulnerabilityProperties() (*SQLServerVulnerabilityProperties, bool) { + return &ssvp, true +} + +// AsContainerRegistryVulnerabilityProperties is the BasicAdditionalData implementation for SQLServerVulnerabilityProperties. +func (ssvp SQLServerVulnerabilityProperties) AsContainerRegistryVulnerabilityProperties() (*ContainerRegistryVulnerabilityProperties, bool) { + return nil, false +} + +// AsServerVulnerabilityProperties is the BasicAdditionalData implementation for SQLServerVulnerabilityProperties. +func (ssvp SQLServerVulnerabilityProperties) AsServerVulnerabilityProperties() (*ServerVulnerabilityProperties, bool) { + return nil, false +} + +// AsAdditionalData is the BasicAdditionalData implementation for SQLServerVulnerabilityProperties. +func (ssvp SQLServerVulnerabilityProperties) AsAdditionalData() (*AdditionalData, bool) { + return nil, false +} + +// AsBasicAdditionalData is the BasicAdditionalData implementation for SQLServerVulnerabilityProperties. +func (ssvp SQLServerVulnerabilityProperties) AsBasicAdditionalData() (BasicAdditionalData, bool) { + return &ssvp, true +} + +// SubAssessment security sub-assessment on a resource +type SubAssessment struct { + autorest.Response `json:"-"` + *SubAssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubAssessment. +func (sa SubAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sa.SubAssessmentProperties != nil { + objectMap["properties"] = sa.SubAssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SubAssessment struct. +func (sa *SubAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var subAssessmentProperties SubAssessmentProperties + err = json.Unmarshal(*v, &subAssessmentProperties) + if err != nil { + return err + } + sa.SubAssessmentProperties = &subAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sa.Type = &typeVar + } + } + } + + return nil +} + +// SubAssessmentList list of security sub-assessments +type SubAssessmentList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY + Value *[]SubAssessment `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// SubAssessmentListIterator provides access to a complete listing of SubAssessment values. +type SubAssessmentListIterator struct { + i int + page SubAssessmentListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SubAssessmentListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubAssessmentListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SubAssessmentListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SubAssessmentListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SubAssessmentListIterator) Response() SubAssessmentList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SubAssessmentListIterator) Value() SubAssessment { + if !iter.page.NotDone() { + return SubAssessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SubAssessmentListIterator type. +func NewSubAssessmentListIterator(page SubAssessmentListPage) SubAssessmentListIterator { + return SubAssessmentListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sal SubAssessmentList) IsEmpty() bool { + return sal.Value == nil || len(*sal.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sal SubAssessmentList) hasNextLink() bool { + return sal.NextLink != nil && len(*sal.NextLink) != 0 +} + +// subAssessmentListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sal SubAssessmentList) subAssessmentListPreparer(ctx context.Context) (*http.Request, error) { + if !sal.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sal.NextLink))) +} + +// SubAssessmentListPage contains a page of SubAssessment values. +type SubAssessmentListPage struct { + fn func(context.Context, SubAssessmentList) (SubAssessmentList, error) + sal SubAssessmentList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SubAssessmentListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubAssessmentListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sal) + if err != nil { + return err + } + page.sal = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SubAssessmentListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SubAssessmentListPage) NotDone() bool { + return !page.sal.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SubAssessmentListPage) Response() SubAssessmentList { + return page.sal +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SubAssessmentListPage) Values() []SubAssessment { + if page.sal.IsEmpty() { + return nil + } + return *page.sal.Value +} + +// Creates a new instance of the SubAssessmentListPage type. +func NewSubAssessmentListPage(getNextPage func(context.Context, SubAssessmentList) (SubAssessmentList, error)) SubAssessmentListPage { + return SubAssessmentListPage{fn: getNextPage} +} + +// SubAssessmentProperties describes properties of an sub-assessment. +type SubAssessmentProperties struct { + // ID - READ-ONLY; Vulnerability ID + ID *string `json:"id,omitempty"` + // DisplayName - READ-ONLY; User friendly display name of the sub-assessment + DisplayName *string `json:"displayName,omitempty"` + Status *SubAssessmentStatus `json:"status,omitempty"` + // Remediation - READ-ONLY; Information on how to remediate this sub-assessment + Remediation *string `json:"remediation,omitempty"` + // Impact - READ-ONLY; Description of the impact of this sub-assessment + Impact *string `json:"impact,omitempty"` + // Category - READ-ONLY; Category of the sub-assessment + Category *string `json:"category,omitempty"` + // Description - READ-ONLY; Human readable description of the assessment status + Description *string `json:"description,omitempty"` + // TimeGenerated - READ-ONLY; The date and time the sub-assessment was generated + TimeGenerated *date.Time `json:"timeGenerated,omitempty"` + ResourceDetails BasicResourceDetails `json:"resourceDetails,omitempty"` + AdditionalData BasicAdditionalData `json:"additionalData,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubAssessmentProperties. +func (sap SubAssessmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sap.Status != nil { + objectMap["status"] = sap.Status + } + objectMap["resourceDetails"] = sap.ResourceDetails + objectMap["additionalData"] = sap.AdditionalData + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SubAssessmentProperties struct. +func (sap *SubAssessmentProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sap.ID = &ID + } + case "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + sap.DisplayName = &displayName + } + case "status": + if v != nil { + var status SubAssessmentStatus + err = json.Unmarshal(*v, &status) + if err != nil { + return err + } + sap.Status = &status + } + case "remediation": + if v != nil { + var remediation string + err = json.Unmarshal(*v, &remediation) + if err != nil { + return err + } + sap.Remediation = &remediation + } + case "impact": + if v != nil { + var impact string + err = json.Unmarshal(*v, &impact) + if err != nil { + return err + } + sap.Impact = &impact + } + case "category": + if v != nil { + var category string + err = json.Unmarshal(*v, &category) + if err != nil { + return err + } + sap.Category = &category + } + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + sap.Description = &description + } + case "timeGenerated": + if v != nil { + var timeGenerated date.Time + err = json.Unmarshal(*v, &timeGenerated) + if err != nil { + return err + } + sap.TimeGenerated = &timeGenerated + } + case "resourceDetails": + if v != nil { + resourceDetails, err := unmarshalBasicResourceDetails(*v) + if err != nil { + return err + } + sap.ResourceDetails = resourceDetails + } + case "additionalData": + if v != nil { + additionalData, err := unmarshalBasicAdditionalData(*v) + if err != nil { + return err + } + sap.AdditionalData = additionalData + } + } + } + + return nil +} + +// SubAssessmentStatus status of the sub-assessment +type SubAssessmentStatus struct { + // Code - READ-ONLY; Programmatic code for the status of the assessment. Possible values include: 'SubAssessmentStatusCodeHealthy', 'SubAssessmentStatusCodeUnhealthy', 'SubAssessmentStatusCodeNotApplicable' + Code SubAssessmentStatusCode `json:"code,omitempty"` + // Cause - READ-ONLY; Programmatic code for the cause of the assessment status + Cause *string `json:"cause,omitempty"` + // Description - READ-ONLY; Human readable description of the assessment status + Description *string `json:"description,omitempty"` + // Severity - READ-ONLY; The sub-assessment severity level. Possible values include: 'SeverityLow', 'SeverityMedium', 'SeverityHigh' + Severity Severity `json:"severity,omitempty"` +} + +// SuppressionAlertsScope ... +type SuppressionAlertsScope struct { + // AllOf - All the conditions inside need to be true in order to suppress the alert + AllOf *[]ScopeElement `json:"allOf,omitempty"` +} + +// Tags a list of key value pairs that describe the resource. +type Tags struct { + // Tags - A list of key value pairs that describe the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Tags. +func (t Tags) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if t.Tags != nil { + objectMap["tags"] = t.Tags + } + return json.Marshal(objectMap) +} + +// TagsResource a container holding only the Tags for a resource, allowing the user to update the tags. +type TagsResource struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TagsResource. +func (tr TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// Task security task that we recommend to do in order to strengthen security +type Task struct { + autorest.Response `json:"-"` + *TaskProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Task. +func (t Task) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if t.TaskProperties != nil { + objectMap["properties"] = t.TaskProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Task struct. +func (t *Task) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var taskProperties TaskProperties + err = json.Unmarshal(*v, &taskProperties) + if err != nil { + return err + } + t.TaskProperties = &taskProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + t.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + t.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + t.Type = &typeVar + } + } + } + + return nil +} + +// TaskList list of security task recommendations +type TaskList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY + Value *[]Task `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// TaskListIterator provides access to a complete listing of Task values. +type TaskListIterator struct { + i int + page TaskListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *TaskListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TaskListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *TaskListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TaskListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter TaskListIterator) Response() TaskList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter TaskListIterator) Value() Task { + if !iter.page.NotDone() { + return Task{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TaskListIterator type. +func NewTaskListIterator(page TaskListPage) TaskListIterator { + return TaskListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tl TaskList) IsEmpty() bool { + return tl.Value == nil || len(*tl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (tl TaskList) hasNextLink() bool { + return tl.NextLink != nil && len(*tl.NextLink) != 0 +} + +// taskListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tl TaskList) taskListPreparer(ctx context.Context) (*http.Request, error) { + if !tl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tl.NextLink))) +} + +// TaskListPage contains a page of Task values. +type TaskListPage struct { + fn func(context.Context, TaskList) (TaskList, error) + tl TaskList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *TaskListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TaskListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.tl) + if err != nil { + return err + } + page.tl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *TaskListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TaskListPage) NotDone() bool { + return !page.tl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TaskListPage) Response() TaskList { + return page.tl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TaskListPage) Values() []Task { + if page.tl.IsEmpty() { + return nil + } + return *page.tl.Value +} + +// Creates a new instance of the TaskListPage type. +func NewTaskListPage(getNextPage func(context.Context, TaskList) (TaskList, error)) TaskListPage { + return TaskListPage{fn: getNextPage} +} + +// TaskParameters changing set of properties, depending on the task type that is derived from the name field +type TaskParameters struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Name - READ-ONLY; Name of the task type + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for TaskParameters. +func (tp TaskParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + for k, v := range tp.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TaskParameters struct. +func (tp *TaskParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if tp.AdditionalProperties == nil { + tp.AdditionalProperties = make(map[string]interface{}) + } + tp.AdditionalProperties[k] = additionalProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tp.Name = &name + } + } + } + + return nil +} + +// TaskProperties describes properties of a task. +type TaskProperties struct { + // State - READ-ONLY; State of the task (Active, Resolved etc.) + State *string `json:"state,omitempty"` + // CreationTimeUtc - READ-ONLY; The time this task was discovered in UTC + CreationTimeUtc *date.Time `json:"creationTimeUtc,omitempty"` + SecurityTaskParameters *TaskParameters `json:"securityTaskParameters,omitempty"` + // LastStateChangeTimeUtc - READ-ONLY; The time this task's details were last changed in UTC + LastStateChangeTimeUtc *date.Time `json:"lastStateChangeTimeUtc,omitempty"` + // SubState - READ-ONLY; Additional data on the state of the task + SubState *string `json:"subState,omitempty"` +} + +// MarshalJSON is the custom marshaler for TaskProperties. +func (tp TaskProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tp.SecurityTaskParameters != nil { + objectMap["securityTaskParameters"] = tp.SecurityTaskParameters + } + return json.Marshal(objectMap) +} + +// BasicThresholdCustomAlertRule a custom alert rule that checks if a value (depends on the custom alert type) is +// within the given range. +type BasicThresholdCustomAlertRule interface { + AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) + AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) + AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) + AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) + AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) + AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) + AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) + AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) + AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) + AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) + AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) + AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) + AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) + AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) + AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) + AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) + AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) + AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) + AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) +} + +// ThresholdCustomAlertRule a custom alert rule that checks if a value (depends on the custom alert type) is +// within the given range. +type ThresholdCustomAlertRule struct { + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +func unmarshalBasicThresholdCustomAlertRule(body []byte) (BasicThresholdCustomAlertRule, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["ruleType"] { + case string(RuleTypeTimeWindowCustomAlertRule): + var twcar TimeWindowCustomAlertRule + err := json.Unmarshal(body, &twcar) + return twcar, err + case string(RuleTypeActiveConnectionsNotInAllowedRange): + var acniar ActiveConnectionsNotInAllowedRange + err := json.Unmarshal(body, &acniar) + return acniar, err + case string(RuleTypeAmqpC2DMessagesNotInAllowedRange): + var acmniar AmqpC2DMessagesNotInAllowedRange + err := json.Unmarshal(body, &acmniar) + return acmniar, err + case string(RuleTypeMqttC2DMessagesNotInAllowedRange): + var mcmniar MqttC2DMessagesNotInAllowedRange + err := json.Unmarshal(body, &mcmniar) + return mcmniar, err + case string(RuleTypeHTTPC2DMessagesNotInAllowedRange): + var hcmniar HTTPC2DMessagesNotInAllowedRange + err := json.Unmarshal(body, &hcmniar) + return hcmniar, err + case string(RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange): + var acrmniar AmqpC2DRejectedMessagesNotInAllowedRange + err := json.Unmarshal(body, &acrmniar) + return acrmniar, err + case string(RuleTypeMqttC2DRejectedMessagesNotInAllowedRange): + var mcrmniar MqttC2DRejectedMessagesNotInAllowedRange + err := json.Unmarshal(body, &mcrmniar) + return mcrmniar, err + case string(RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange): + var hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange + err := json.Unmarshal(body, &hcrmniar) + return hcrmniar, err + case string(RuleTypeAmqpD2CMessagesNotInAllowedRange): + var admniar AmqpD2CMessagesNotInAllowedRange + err := json.Unmarshal(body, &admniar) + return admniar, err + case string(RuleTypeMqttD2CMessagesNotInAllowedRange): + var mdmniar MqttD2CMessagesNotInAllowedRange + err := json.Unmarshal(body, &mdmniar) + return mdmniar, err + case string(RuleTypeHTTPD2CMessagesNotInAllowedRange): + var hdmniar HTTPD2CMessagesNotInAllowedRange + err := json.Unmarshal(body, &hdmniar) + return hdmniar, err + case string(RuleTypeDirectMethodInvokesNotInAllowedRange): + var dminiar DirectMethodInvokesNotInAllowedRange + err := json.Unmarshal(body, &dminiar) + return dminiar, err + case string(RuleTypeFailedLocalLoginsNotInAllowedRange): + var fllniar FailedLocalLoginsNotInAllowedRange + err := json.Unmarshal(body, &fllniar) + return fllniar, err + case string(RuleTypeFileUploadsNotInAllowedRange): + var funiar FileUploadsNotInAllowedRange + err := json.Unmarshal(body, &funiar) + return funiar, err + case string(RuleTypeQueuePurgesNotInAllowedRange): + var qpniar QueuePurgesNotInAllowedRange + err := json.Unmarshal(body, &qpniar) + return qpniar, err + case string(RuleTypeTwinUpdatesNotInAllowedRange): + var tuniar TwinUpdatesNotInAllowedRange + err := json.Unmarshal(body, &tuniar) + return tuniar, err + case string(RuleTypeUnauthorizedOperationsNotInAllowedRange): + var uoniar UnauthorizedOperationsNotInAllowedRange + err := json.Unmarshal(body, &uoniar) + return uoniar, err + default: + var tcar ThresholdCustomAlertRule + err := json.Unmarshal(body, &tcar) + return tcar, err + } +} +func unmarshalBasicThresholdCustomAlertRuleArray(body []byte) ([]BasicThresholdCustomAlertRule, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + tcarArray := make([]BasicThresholdCustomAlertRule, len(rawMessages)) + + for index, rawMessage := range rawMessages { + tcar, err := unmarshalBasicThresholdCustomAlertRule(*rawMessage) + if err != nil { + return nil, err + } + tcarArray[index] = tcar + } + return tcarArray, nil +} + +// MarshalJSON is the custom marshaler for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) MarshalJSON() ([]byte, error) { + tcar.RuleType = RuleTypeThresholdCustomAlertRule + objectMap := make(map[string]interface{}) + if tcar.MinThreshold != nil { + objectMap["minThreshold"] = tcar.MinThreshold + } + if tcar.MaxThreshold != nil { + objectMap["maxThreshold"] = tcar.MaxThreshold + } + if tcar.IsEnabled != nil { + objectMap["isEnabled"] = tcar.IsEnabled + } + if tcar.RuleType != "" { + objectMap["ruleType"] = tcar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return &tcar, true +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &tcar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for ThresholdCustomAlertRule. +func (tcar ThresholdCustomAlertRule) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &tcar, true +} + +// BasicTimeWindowCustomAlertRule a custom alert rule that checks if the number of activities (depends on the custom +// alert type) in a time window is within the given range. +type BasicTimeWindowCustomAlertRule interface { + AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) + AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) + AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) + AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) + AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) + AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) + AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) + AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) + AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) + AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) + AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) + AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) + AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) + AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) + AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) + AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) + AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) +} + +// TimeWindowCustomAlertRule a custom alert rule that checks if the number of activities (depends on the custom +// alert type) in a time window is within the given range. +type TimeWindowCustomAlertRule struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +func unmarshalBasicTimeWindowCustomAlertRule(body []byte) (BasicTimeWindowCustomAlertRule, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["ruleType"] { + case string(RuleTypeActiveConnectionsNotInAllowedRange): + var acniar ActiveConnectionsNotInAllowedRange + err := json.Unmarshal(body, &acniar) + return acniar, err + case string(RuleTypeAmqpC2DMessagesNotInAllowedRange): + var acmniar AmqpC2DMessagesNotInAllowedRange + err := json.Unmarshal(body, &acmniar) + return acmniar, err + case string(RuleTypeMqttC2DMessagesNotInAllowedRange): + var mcmniar MqttC2DMessagesNotInAllowedRange + err := json.Unmarshal(body, &mcmniar) + return mcmniar, err + case string(RuleTypeHTTPC2DMessagesNotInAllowedRange): + var hcmniar HTTPC2DMessagesNotInAllowedRange + err := json.Unmarshal(body, &hcmniar) + return hcmniar, err + case string(RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange): + var acrmniar AmqpC2DRejectedMessagesNotInAllowedRange + err := json.Unmarshal(body, &acrmniar) + return acrmniar, err + case string(RuleTypeMqttC2DRejectedMessagesNotInAllowedRange): + var mcrmniar MqttC2DRejectedMessagesNotInAllowedRange + err := json.Unmarshal(body, &mcrmniar) + return mcrmniar, err + case string(RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange): + var hcrmniar HTTPC2DRejectedMessagesNotInAllowedRange + err := json.Unmarshal(body, &hcrmniar) + return hcrmniar, err + case string(RuleTypeAmqpD2CMessagesNotInAllowedRange): + var admniar AmqpD2CMessagesNotInAllowedRange + err := json.Unmarshal(body, &admniar) + return admniar, err + case string(RuleTypeMqttD2CMessagesNotInAllowedRange): + var mdmniar MqttD2CMessagesNotInAllowedRange + err := json.Unmarshal(body, &mdmniar) + return mdmniar, err + case string(RuleTypeHTTPD2CMessagesNotInAllowedRange): + var hdmniar HTTPD2CMessagesNotInAllowedRange + err := json.Unmarshal(body, &hdmniar) + return hdmniar, err + case string(RuleTypeDirectMethodInvokesNotInAllowedRange): + var dminiar DirectMethodInvokesNotInAllowedRange + err := json.Unmarshal(body, &dminiar) + return dminiar, err + case string(RuleTypeFailedLocalLoginsNotInAllowedRange): + var fllniar FailedLocalLoginsNotInAllowedRange + err := json.Unmarshal(body, &fllniar) + return fllniar, err + case string(RuleTypeFileUploadsNotInAllowedRange): + var funiar FileUploadsNotInAllowedRange + err := json.Unmarshal(body, &funiar) + return funiar, err + case string(RuleTypeQueuePurgesNotInAllowedRange): + var qpniar QueuePurgesNotInAllowedRange + err := json.Unmarshal(body, &qpniar) + return qpniar, err + case string(RuleTypeTwinUpdatesNotInAllowedRange): + var tuniar TwinUpdatesNotInAllowedRange + err := json.Unmarshal(body, &tuniar) + return tuniar, err + case string(RuleTypeUnauthorizedOperationsNotInAllowedRange): + var uoniar UnauthorizedOperationsNotInAllowedRange + err := json.Unmarshal(body, &uoniar) + return uoniar, err + default: + var twcar TimeWindowCustomAlertRule + err := json.Unmarshal(body, &twcar) + return twcar, err + } +} +func unmarshalBasicTimeWindowCustomAlertRuleArray(body []byte) ([]BasicTimeWindowCustomAlertRule, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + twcarArray := make([]BasicTimeWindowCustomAlertRule, len(rawMessages)) + + for index, rawMessage := range rawMessages { + twcar, err := unmarshalBasicTimeWindowCustomAlertRule(*rawMessage) + if err != nil { + return nil, err + } + twcarArray[index] = twcar + } + return twcarArray, nil +} + +// MarshalJSON is the custom marshaler for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) MarshalJSON() ([]byte, error) { + twcar.RuleType = RuleTypeTimeWindowCustomAlertRule + objectMap := make(map[string]interface{}) + if twcar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = twcar.TimeWindowSize + } + if twcar.MinThreshold != nil { + objectMap["minThreshold"] = twcar.MinThreshold + } + if twcar.MaxThreshold != nil { + objectMap["maxThreshold"] = twcar.MaxThreshold + } + if twcar.IsEnabled != nil { + objectMap["isEnabled"] = twcar.IsEnabled + } + if twcar.RuleType != "" { + objectMap["ruleType"] = twcar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &twcar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return &twcar, true +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &twcar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for TimeWindowCustomAlertRule. +func (twcar TimeWindowCustomAlertRule) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &twcar, true +} + +// TopologyList ... +type TopologyList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY + Value *[]TopologyResource `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// TopologyListIterator provides access to a complete listing of TopologyResource values. +type TopologyListIterator struct { + i int + page TopologyListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *TopologyListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopologyListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *TopologyListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TopologyListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter TopologyListIterator) Response() TopologyList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter TopologyListIterator) Value() TopologyResource { + if !iter.page.NotDone() { + return TopologyResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TopologyListIterator type. +func NewTopologyListIterator(page TopologyListPage) TopologyListIterator { + return TopologyListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tl TopologyList) IsEmpty() bool { + return tl.Value == nil || len(*tl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (tl TopologyList) hasNextLink() bool { + return tl.NextLink != nil && len(*tl.NextLink) != 0 +} + +// topologyListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tl TopologyList) topologyListPreparer(ctx context.Context) (*http.Request, error) { + if !tl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tl.NextLink))) +} + +// TopologyListPage contains a page of TopologyResource values. +type TopologyListPage struct { + fn func(context.Context, TopologyList) (TopologyList, error) + tl TopologyList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *TopologyListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopologyListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.tl) + if err != nil { + return err + } + page.tl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *TopologyListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TopologyListPage) NotDone() bool { + return !page.tl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TopologyListPage) Response() TopologyList { + return page.tl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TopologyListPage) Values() []TopologyResource { + if page.tl.IsEmpty() { + return nil + } + return *page.tl.Value +} + +// Creates a new instance of the TopologyListPage type. +func NewTopologyListPage(getNextPage func(context.Context, TopologyList) (TopologyList, error)) TopologyListPage { + return TopologyListPage{fn: getNextPage} +} + +// TopologyResource ... +type TopologyResource struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + // TopologyResourceProperties - READ-ONLY + *TopologyResourceProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for TopologyResource. +func (tr TopologyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TopologyResource struct. +func (tr *TopologyResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tr.Location = &location + } + case "properties": + if v != nil { + var topologyResourceProperties TopologyResourceProperties + err = json.Unmarshal(*v, &topologyResourceProperties) + if err != nil { + return err + } + tr.TopologyResourceProperties = &topologyResourceProperties + } + } + } + + return nil +} + +// TopologyResourceProperties ... +type TopologyResourceProperties struct { + // CalculatedDateTime - READ-ONLY; The UTC time on which the topology was calculated + CalculatedDateTime *date.Time `json:"calculatedDateTime,omitempty"` + // TopologyResources - READ-ONLY; Azure resources which are part of this topology resource + TopologyResources *[]TopologySingleResource `json:"topologyResources,omitempty"` +} + +// TopologySingleResource ... +type TopologySingleResource struct { + // ResourceID - READ-ONLY; Azure resource id + ResourceID *string `json:"resourceId,omitempty"` + // Severity - READ-ONLY; The security severity of the resource + Severity *string `json:"severity,omitempty"` + // RecommendationsExist - READ-ONLY; Indicates if the resource has security recommendations + RecommendationsExist *bool `json:"recommendationsExist,omitempty"` + // NetworkZones - READ-ONLY; Indicates the resource connectivity level to the Internet (InternetFacing, Internal ,etc.) + NetworkZones *string `json:"networkZones,omitempty"` + // TopologyScore - READ-ONLY; Score of the resource based on its security severity + TopologyScore *int32 `json:"topologyScore,omitempty"` + // Location - READ-ONLY; The location of this resource + Location *string `json:"location,omitempty"` + // Parents - READ-ONLY; Azure resources connected to this resource which are in higher level in the topology view + Parents *[]TopologySingleResourceParent `json:"parents,omitempty"` + // Children - READ-ONLY; Azure resources connected to this resource which are in lower level in the topology view + Children *[]TopologySingleResourceChild `json:"children,omitempty"` +} + +// TopologySingleResourceChild ... +type TopologySingleResourceChild struct { + // ResourceID - READ-ONLY; Azure resource id which serves as child resource in topology view + ResourceID *string `json:"resourceId,omitempty"` +} + +// TopologySingleResourceParent ... +type TopologySingleResourceParent struct { + // ResourceID - READ-ONLY; Azure resource id which serves as parent resource in topology view + ResourceID *string `json:"resourceId,omitempty"` +} + +// TrackedResource describes an Azure tracked resource. +type TrackedResource struct { + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Location where the resource is stored + Location *string `json:"location,omitempty"` + // Kind - Kind of the resource + Kind *string `json:"kind,omitempty"` + // Etag - Entity tag is used for comparing two or more entities from the same requested resource. + Etag *string `json:"etag,omitempty"` + // Tags - A list of key value pairs that describe the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Kind != nil { + objectMap["kind"] = tr.Kind + } + if tr.Etag != nil { + objectMap["etag"] = tr.Etag + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// TwinUpdatesNotInAllowedRange number of twin updates is not in allowed range. +type TwinUpdatesNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) MarshalJSON() ([]byte, error) { + tuniar.RuleType = RuleTypeTwinUpdatesNotInAllowedRange + objectMap := make(map[string]interface{}) + if tuniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = tuniar.TimeWindowSize + } + if tuniar.MinThreshold != nil { + objectMap["minThreshold"] = tuniar.MinThreshold + } + if tuniar.MaxThreshold != nil { + objectMap["maxThreshold"] = tuniar.MaxThreshold + } + if tuniar.IsEnabled != nil { + objectMap["isEnabled"] = tuniar.IsEnabled + } + if tuniar.RuleType != "" { + objectMap["ruleType"] = tuniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &tuniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &tuniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return &tuniar, true +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return nil, false +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for TwinUpdatesNotInAllowedRange. +func (tuniar TwinUpdatesNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &tuniar, true +} + +// UnauthorizedOperationsNotInAllowedRange number of unauthorized operations is not in allowed range. +type UnauthorizedOperationsNotInAllowedRange struct { + // TimeWindowSize - The time window size in iso8601 format. + TimeWindowSize *string `json:"timeWindowSize,omitempty"` + // MinThreshold - The minimum threshold. + MinThreshold *int32 `json:"minThreshold,omitempty"` + // MaxThreshold - The maximum threshold. + MaxThreshold *int32 `json:"maxThreshold,omitempty"` + // DisplayName - READ-ONLY; The display name of the custom alert. + DisplayName *string `json:"displayName,omitempty"` + // Description - READ-ONLY; The description of the custom alert. + Description *string `json:"description,omitempty"` + // IsEnabled - Status of the custom alert. + IsEnabled *bool `json:"isEnabled,omitempty"` + // RuleType - Possible values include: 'RuleTypeCustomAlertRule', 'RuleTypeThresholdCustomAlertRule', 'RuleTypeTimeWindowCustomAlertRule', 'RuleTypeAllowlistCustomAlertRule', 'RuleTypeDenylistCustomAlertRule', 'RuleTypeListCustomAlertRule', 'RuleTypeConnectionToIPNotAllowed', 'RuleTypeLocalUserNotAllowed', 'RuleTypeProcessNotAllowed', 'RuleTypeActiveConnectionsNotInAllowedRange', 'RuleTypeAmqpC2DMessagesNotInAllowedRange', 'RuleTypeMqttC2DMessagesNotInAllowedRange', 'RuleTypeHTTPC2DMessagesNotInAllowedRange', 'RuleTypeAmqpC2DRejectedMessagesNotInAllowedRange', 'RuleTypeMqttC2DRejectedMessagesNotInAllowedRange', 'RuleTypeHTTPC2DRejectedMessagesNotInAllowedRange', 'RuleTypeAmqpD2CMessagesNotInAllowedRange', 'RuleTypeMqttD2CMessagesNotInAllowedRange', 'RuleTypeHTTPD2CMessagesNotInAllowedRange', 'RuleTypeDirectMethodInvokesNotInAllowedRange', 'RuleTypeFailedLocalLoginsNotInAllowedRange', 'RuleTypeFileUploadsNotInAllowedRange', 'RuleTypeQueuePurgesNotInAllowedRange', 'RuleTypeTwinUpdatesNotInAllowedRange', 'RuleTypeUnauthorizedOperationsNotInAllowedRange' + RuleType RuleType `json:"ruleType,omitempty"` +} + +// MarshalJSON is the custom marshaler for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) MarshalJSON() ([]byte, error) { + uoniar.RuleType = RuleTypeUnauthorizedOperationsNotInAllowedRange + objectMap := make(map[string]interface{}) + if uoniar.TimeWindowSize != nil { + objectMap["timeWindowSize"] = uoniar.TimeWindowSize + } + if uoniar.MinThreshold != nil { + objectMap["minThreshold"] = uoniar.MinThreshold + } + if uoniar.MaxThreshold != nil { + objectMap["maxThreshold"] = uoniar.MaxThreshold + } + if uoniar.IsEnabled != nil { + objectMap["isEnabled"] = uoniar.IsEnabled + } + if uoniar.RuleType != "" { + objectMap["ruleType"] = uoniar.RuleType + } + return json.Marshal(objectMap) +} + +// AsThresholdCustomAlertRule is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsThresholdCustomAlertRule() (*ThresholdCustomAlertRule, bool) { + return nil, false +} + +// AsBasicThresholdCustomAlertRule is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsBasicThresholdCustomAlertRule() (BasicThresholdCustomAlertRule, bool) { + return &uoniar, true +} + +// AsTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsTimeWindowCustomAlertRule() (*TimeWindowCustomAlertRule, bool) { + return nil, false +} + +// AsBasicTimeWindowCustomAlertRule is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsBasicTimeWindowCustomAlertRule() (BasicTimeWindowCustomAlertRule, bool) { + return &uoniar, true +} + +// AsAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsAllowlistCustomAlertRule() (*AllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsBasicAllowlistCustomAlertRule is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsBasicAllowlistCustomAlertRule() (BasicAllowlistCustomAlertRule, bool) { + return nil, false +} + +// AsDenylistCustomAlertRule is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsDenylistCustomAlertRule() (*DenylistCustomAlertRule, bool) { + return nil, false +} + +// AsListCustomAlertRule is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsListCustomAlertRule() (*ListCustomAlertRule, bool) { + return nil, false +} + +// AsBasicListCustomAlertRule is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsBasicListCustomAlertRule() (BasicListCustomAlertRule, bool) { + return nil, false +} + +// AsConnectionToIPNotAllowed is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsConnectionToIPNotAllowed() (*ConnectionToIPNotAllowed, bool) { + return nil, false +} + +// AsLocalUserNotAllowed is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsLocalUserNotAllowed() (*LocalUserNotAllowed, bool) { + return nil, false +} + +// AsProcessNotAllowed is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsProcessNotAllowed() (*ProcessNotAllowed, bool) { + return nil, false +} + +// AsActiveConnectionsNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsActiveConnectionsNotInAllowedRange() (*ActiveConnectionsNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsAmqpC2DMessagesNotInAllowedRange() (*AmqpC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsMqttC2DMessagesNotInAllowedRange() (*MqttC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsHTTPC2DMessagesNotInAllowedRange() (*HTTPC2DMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsAmqpC2DRejectedMessagesNotInAllowedRange() (*AmqpC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsMqttC2DRejectedMessagesNotInAllowedRange() (*MqttC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPC2DRejectedMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsHTTPC2DRejectedMessagesNotInAllowedRange() (*HTTPC2DRejectedMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsAmqpD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsAmqpD2CMessagesNotInAllowedRange() (*AmqpD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsMqttD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsMqttD2CMessagesNotInAllowedRange() (*MqttD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsHTTPD2CMessagesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsHTTPD2CMessagesNotInAllowedRange() (*HTTPD2CMessagesNotInAllowedRange, bool) { + return nil, false +} + +// AsDirectMethodInvokesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsDirectMethodInvokesNotInAllowedRange() (*DirectMethodInvokesNotInAllowedRange, bool) { + return nil, false +} + +// AsFailedLocalLoginsNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsFailedLocalLoginsNotInAllowedRange() (*FailedLocalLoginsNotInAllowedRange, bool) { + return nil, false +} + +// AsFileUploadsNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsFileUploadsNotInAllowedRange() (*FileUploadsNotInAllowedRange, bool) { + return nil, false +} + +// AsQueuePurgesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsQueuePurgesNotInAllowedRange() (*QueuePurgesNotInAllowedRange, bool) { + return nil, false +} + +// AsTwinUpdatesNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsTwinUpdatesNotInAllowedRange() (*TwinUpdatesNotInAllowedRange, bool) { + return nil, false +} + +// AsUnauthorizedOperationsNotInAllowedRange is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsUnauthorizedOperationsNotInAllowedRange() (*UnauthorizedOperationsNotInAllowedRange, bool) { + return &uoniar, true +} + +// AsCustomAlertRule is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsCustomAlertRule() (*CustomAlertRule, bool) { + return nil, false +} + +// AsBasicCustomAlertRule is the BasicCustomAlertRule implementation for UnauthorizedOperationsNotInAllowedRange. +func (uoniar UnauthorizedOperationsNotInAllowedRange) AsBasicCustomAlertRule() (BasicCustomAlertRule, bool) { + return &uoniar, true +} + +// UpdateIotSecuritySolutionData ... +type UpdateIotSecuritySolutionData struct { + // UpdateIoTSecuritySolutionProperties - Security Solution data + *UpdateIoTSecuritySolutionProperties `json:"properties,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for UpdateIotSecuritySolutionData. +func (uissd UpdateIotSecuritySolutionData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if uissd.UpdateIoTSecuritySolutionProperties != nil { + objectMap["properties"] = uissd.UpdateIoTSecuritySolutionProperties + } + if uissd.Tags != nil { + objectMap["tags"] = uissd.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for UpdateIotSecuritySolutionData struct. +func (uissd *UpdateIotSecuritySolutionData) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var updateIoTSecuritySolutionProperties UpdateIoTSecuritySolutionProperties + err = json.Unmarshal(*v, &updateIoTSecuritySolutionProperties) + if err != nil { + return err + } + uissd.UpdateIoTSecuritySolutionProperties = &updateIoTSecuritySolutionProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + uissd.Tags = tags + } + } + } + + return nil +} + +// UpdateIoTSecuritySolutionProperties update Security Solution setting data +type UpdateIoTSecuritySolutionProperties struct { + UserDefinedResources *UserDefinedResourcesProperties `json:"userDefinedResources,omitempty"` + RecommendationsConfiguration *[]RecommendationConfigurationProperties `json:"recommendationsConfiguration,omitempty"` +} + +// UserDefinedResourcesProperties properties of the IoT Security solution's user defined resources. +type UserDefinedResourcesProperties struct { + // Query - Azure Resource Graph query which represents the security solution's user defined resources. Required to start with "where type != "Microsoft.Devices/IotHubs"" + Query *string `json:"query,omitempty"` + // QuerySubscriptions - List of Azure subscription ids on which the user defined resources query should be executed. + QuerySubscriptions *[]string `json:"querySubscriptions,omitempty"` +} + +// UserRecommendation represents a user that is recommended to be allowed for a certain rule +type UserRecommendation struct { + // Username - Represents a user that is recommended to be allowed for a certain rule + Username *string `json:"username,omitempty"` + // RecommendationAction - Possible values include: 'RecommendationAction1Recommended', 'RecommendationAction1Add', 'RecommendationAction1Remove' + RecommendationAction RecommendationAction1 `json:"recommendationAction,omitempty"` +} + +// VendorReference vendor reference +type VendorReference struct { + // Title - READ-ONLY; Link title + Title *string `json:"title,omitempty"` + // Link - READ-ONLY; Link url + Link *string `json:"link,omitempty"` +} + +// VMRecommendation represents a machine that is part of a machine group +type VMRecommendation struct { + // ConfigurationStatus - Possible values include: 'Configured', 'NotConfigured', 'InProgress', 'Failed', 'NoStatus' + ConfigurationStatus ConfigurationStatus `json:"configurationStatus,omitempty"` + // RecommendationAction - Possible values include: 'RecommendationActionRecommended', 'RecommendationActionAdd', 'RecommendationActionRemove' + RecommendationAction RecommendationAction `json:"recommendationAction,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + // EnforcementSupport - Possible values include: 'EnforcementSupportSupported', 'EnforcementSupportNotSupported', 'EnforcementSupportUnknown' + EnforcementSupport EnforcementSupport `json:"enforcementSupport,omitempty"` +} + +// WorkspaceSetting configures where to store the OMS agent data for workspaces under a scope +type WorkspaceSetting struct { + autorest.Response `json:"-"` + // WorkspaceSettingProperties - Workspace setting data + *WorkspaceSettingProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkspaceSetting. +func (ws WorkspaceSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ws.WorkspaceSettingProperties != nil { + objectMap["properties"] = ws.WorkspaceSettingProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkspaceSetting struct. +func (ws *WorkspaceSetting) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workspaceSettingProperties WorkspaceSettingProperties + err = json.Unmarshal(*v, &workspaceSettingProperties) + if err != nil { + return err + } + ws.WorkspaceSettingProperties = &workspaceSettingProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ws.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ws.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ws.Type = &typeVar + } + } + } + + return nil +} + +// WorkspaceSettingList list of workspace settings response +type WorkspaceSettingList struct { + autorest.Response `json:"-"` + // Value - List of workspace settings + Value *[]WorkspaceSetting `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkspaceSettingList. +func (wsl WorkspaceSettingList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wsl.Value != nil { + objectMap["value"] = wsl.Value + } + return json.Marshal(objectMap) +} + +// WorkspaceSettingListIterator provides access to a complete listing of WorkspaceSetting values. +type WorkspaceSettingListIterator struct { + i int + page WorkspaceSettingListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkspaceSettingListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceSettingListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkspaceSettingListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkspaceSettingListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkspaceSettingListIterator) Response() WorkspaceSettingList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkspaceSettingListIterator) Value() WorkspaceSetting { + if !iter.page.NotDone() { + return WorkspaceSetting{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkspaceSettingListIterator type. +func NewWorkspaceSettingListIterator(page WorkspaceSettingListPage) WorkspaceSettingListIterator { + return WorkspaceSettingListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wsl WorkspaceSettingList) IsEmpty() bool { + return wsl.Value == nil || len(*wsl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wsl WorkspaceSettingList) hasNextLink() bool { + return wsl.NextLink != nil && len(*wsl.NextLink) != 0 +} + +// workspaceSettingListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wsl WorkspaceSettingList) workspaceSettingListPreparer(ctx context.Context) (*http.Request, error) { + if !wsl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wsl.NextLink))) +} + +// WorkspaceSettingListPage contains a page of WorkspaceSetting values. +type WorkspaceSettingListPage struct { + fn func(context.Context, WorkspaceSettingList) (WorkspaceSettingList, error) + wsl WorkspaceSettingList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkspaceSettingListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceSettingListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wsl) + if err != nil { + return err + } + page.wsl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkspaceSettingListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkspaceSettingListPage) NotDone() bool { + return !page.wsl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkspaceSettingListPage) Response() WorkspaceSettingList { + return page.wsl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkspaceSettingListPage) Values() []WorkspaceSetting { + if page.wsl.IsEmpty() { + return nil + } + return *page.wsl.Value +} + +// Creates a new instance of the WorkspaceSettingListPage type. +func NewWorkspaceSettingListPage(getNextPage func(context.Context, WorkspaceSettingList) (WorkspaceSettingList, error)) WorkspaceSettingListPage { + return WorkspaceSettingListPage{fn: getNextPage} +} + +// WorkspaceSettingProperties workspace setting data +type WorkspaceSettingProperties struct { + // WorkspaceID - The full Azure ID of the workspace to save the data in + WorkspaceID *string `json:"workspaceId,omitempty"` + // Scope - All the VMs in this scope will send their security data to the mentioned workspace unless overridden by a setting with more specific scope + Scope *string `json:"scope,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/operations.go new file mode 100644 index 0000000000000..7c0687ccd870a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/operations.go @@ -0,0 +1,149 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string, ascLocation string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// List exposes all available operations for discovery purposes. +func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.OperationsClient", "List", resp, "Failure responding to request") + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Security/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) { + req, err := lastResults.operationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/pricings.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/pricings.go new file mode 100644 index 0000000000000..4a7b973d2049a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/pricings.go @@ -0,0 +1,280 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PricingsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type PricingsClient struct { + BaseClient +} + +// NewPricingsClient creates an instance of the PricingsClient client. +func NewPricingsClient(subscriptionID string, ascLocation string) PricingsClient { + return NewPricingsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewPricingsClientWithBaseURI creates an instance of the PricingsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPricingsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) PricingsClient { + return PricingsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get gets a provided Security Center pricing configuration in the subscription. +// Parameters: +// pricingName - name of the pricing configuration +func (client PricingsClient) Get(ctx context.Context, pricingName string) (result Pricing, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PricingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.PricingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, pricingName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.PricingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.PricingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.PricingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PricingsClient) GetPreparer(ctx context.Context, pricingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "pricingName": autorest.Encode("path", pricingName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PricingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PricingsClient) GetResponder(resp *http.Response) (result Pricing, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists Security Center pricing configurations in the subscription. +func (client PricingsClient) List(ctx context.Context) (result PricingList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PricingsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.PricingsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.PricingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.PricingsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.PricingsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client PricingsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PricingsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PricingsClient) ListResponder(resp *http.Response) (result PricingList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a provided Security Center pricing configuration in the subscription. +// Parameters: +// pricingName - name of the pricing configuration +// pricing - pricing object +func (client PricingsClient) Update(ctx context.Context, pricingName string, pricing Pricing) (result Pricing, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PricingsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.PricingsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, pricingName, pricing) + if err != nil { + err = autorest.NewErrorWithError(err, "security.PricingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.PricingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.PricingsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PricingsClient) UpdatePreparer(ctx context.Context, pricingName string, pricing Pricing) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "pricingName": autorest.Encode("path", pricingName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}", pathParameters), + autorest.WithJSON(pricing), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PricingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PricingsClient) UpdateResponder(resp *http.Response) (result Pricing, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycomplianceassessments.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycomplianceassessments.go new file mode 100644 index 0000000000000..64de12cdf182b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycomplianceassessments.go @@ -0,0 +1,254 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegulatoryComplianceAssessmentsClient is the API spec for Microsoft.Security (Azure Security Center) resource +// provider +type RegulatoryComplianceAssessmentsClient struct { + BaseClient +} + +// NewRegulatoryComplianceAssessmentsClient creates an instance of the RegulatoryComplianceAssessmentsClient client. +func NewRegulatoryComplianceAssessmentsClient(subscriptionID string, ascLocation string) RegulatoryComplianceAssessmentsClient { + return NewRegulatoryComplianceAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewRegulatoryComplianceAssessmentsClientWithBaseURI creates an instance of the RegulatoryComplianceAssessmentsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewRegulatoryComplianceAssessmentsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceAssessmentsClient { + return RegulatoryComplianceAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get supported regulatory compliance details and state for selected assessment +// Parameters: +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// regulatoryComplianceControlName - name of the regulatory compliance control object +// regulatoryComplianceAssessmentName - name of the regulatory compliance assessment object +func (client RegulatoryComplianceAssessmentsClient) Get(ctx context.Context, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, regulatoryComplianceAssessmentName string) (result RegulatoryComplianceAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceAssessmentsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, regulatoryComplianceStandardName, regulatoryComplianceControlName, regulatoryComplianceAssessmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegulatoryComplianceAssessmentsClient) GetPreparer(ctx context.Context, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, regulatoryComplianceAssessmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceAssessmentName": autorest.Encode("path", regulatoryComplianceAssessmentName), + "regulatoryComplianceControlName": autorest.Encode("path", regulatoryComplianceControlName), + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments/{regulatoryComplianceAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceAssessmentsClient) GetResponder(resp *http.Response) (result RegulatoryComplianceAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List details and state of assessments mapped to selected regulatory compliance control +// Parameters: +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// regulatoryComplianceControlName - name of the regulatory compliance control object +// filter - oData filter. Optional. +func (client RegulatoryComplianceAssessmentsClient) List(ctx context.Context, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, filter string) (result RegulatoryComplianceAssessmentListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentsClient.List") + defer func() { + sc := -1 + if result.rcal.Response.Response != nil { + sc = result.rcal.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceAssessmentsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, regulatoryComplianceStandardName, regulatoryComplianceControlName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rcal.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "List", resp, "Failure sending request") + return + } + + result.rcal, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "List", resp, "Failure responding to request") + } + if result.rcal.hasNextLink() && result.rcal.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client RegulatoryComplianceAssessmentsClient) ListPreparer(ctx context.Context, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceControlName": autorest.Encode("path", regulatoryComplianceControlName), + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceAssessmentsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceAssessmentsClient) ListResponder(resp *http.Response) (result RegulatoryComplianceAssessmentList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client RegulatoryComplianceAssessmentsClient) listNextResults(ctx context.Context, lastResults RegulatoryComplianceAssessmentList) (result RegulatoryComplianceAssessmentList, err error) { + req, err := lastResults.regulatoryComplianceAssessmentListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceAssessmentsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegulatoryComplianceAssessmentsClient) ListComplete(ctx context.Context, regulatoryComplianceStandardName string, regulatoryComplianceControlName string, filter string) (result RegulatoryComplianceAssessmentListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceAssessmentsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, regulatoryComplianceStandardName, regulatoryComplianceControlName, filter) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycompliancecontrols.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycompliancecontrols.go new file mode 100644 index 0000000000000..069e0c6880db3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycompliancecontrols.go @@ -0,0 +1,249 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegulatoryComplianceControlsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type RegulatoryComplianceControlsClient struct { + BaseClient +} + +// NewRegulatoryComplianceControlsClient creates an instance of the RegulatoryComplianceControlsClient client. +func NewRegulatoryComplianceControlsClient(subscriptionID string, ascLocation string) RegulatoryComplianceControlsClient { + return NewRegulatoryComplianceControlsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewRegulatoryComplianceControlsClientWithBaseURI creates an instance of the RegulatoryComplianceControlsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewRegulatoryComplianceControlsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceControlsClient { + return RegulatoryComplianceControlsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get selected regulatory compliance control details and state +// Parameters: +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// regulatoryComplianceControlName - name of the regulatory compliance control object +func (client RegulatoryComplianceControlsClient) Get(ctx context.Context, regulatoryComplianceStandardName string, regulatoryComplianceControlName string) (result RegulatoryComplianceControl, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceControlsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, regulatoryComplianceStandardName, regulatoryComplianceControlName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegulatoryComplianceControlsClient) GetPreparer(ctx context.Context, regulatoryComplianceStandardName string, regulatoryComplianceControlName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceControlName": autorest.Encode("path", regulatoryComplianceControlName), + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceControlsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceControlsClient) GetResponder(resp *http.Response) (result RegulatoryComplianceControl, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List all supported regulatory compliance controls details and state for selected standard +// Parameters: +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +// filter - oData filter. Optional. +func (client RegulatoryComplianceControlsClient) List(ctx context.Context, regulatoryComplianceStandardName string, filter string) (result RegulatoryComplianceControlListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlsClient.List") + defer func() { + sc := -1 + if result.rccl.Response.Response != nil { + sc = result.rccl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceControlsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, regulatoryComplianceStandardName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rccl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "List", resp, "Failure sending request") + return + } + + result.rccl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "List", resp, "Failure responding to request") + } + if result.rccl.hasNextLink() && result.rccl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client RegulatoryComplianceControlsClient) ListPreparer(ctx context.Context, regulatoryComplianceStandardName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceControlsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceControlsClient) ListResponder(resp *http.Response) (result RegulatoryComplianceControlList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client RegulatoryComplianceControlsClient) listNextResults(ctx context.Context, lastResults RegulatoryComplianceControlList) (result RegulatoryComplianceControlList, err error) { + req, err := lastResults.regulatoryComplianceControlListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceControlsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegulatoryComplianceControlsClient) ListComplete(ctx context.Context, regulatoryComplianceStandardName string, filter string) (result RegulatoryComplianceControlListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceControlsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, regulatoryComplianceStandardName, filter) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycompliancestandards.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycompliancestandards.go new file mode 100644 index 0000000000000..62e3a715ae300 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/regulatorycompliancestandards.go @@ -0,0 +1,245 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RegulatoryComplianceStandardsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type RegulatoryComplianceStandardsClient struct { + BaseClient +} + +// NewRegulatoryComplianceStandardsClient creates an instance of the RegulatoryComplianceStandardsClient client. +func NewRegulatoryComplianceStandardsClient(subscriptionID string, ascLocation string) RegulatoryComplianceStandardsClient { + return NewRegulatoryComplianceStandardsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewRegulatoryComplianceStandardsClientWithBaseURI creates an instance of the RegulatoryComplianceStandardsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewRegulatoryComplianceStandardsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) RegulatoryComplianceStandardsClient { + return RegulatoryComplianceStandardsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get supported regulatory compliance details state for selected standard +// Parameters: +// regulatoryComplianceStandardName - name of the regulatory compliance standard object +func (client RegulatoryComplianceStandardsClient) Get(ctx context.Context, regulatoryComplianceStandardName string) (result RegulatoryComplianceStandard, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceStandardsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, regulatoryComplianceStandardName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RegulatoryComplianceStandardsClient) GetPreparer(ctx context.Context, regulatoryComplianceStandardName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "regulatoryComplianceStandardName": autorest.Encode("path", regulatoryComplianceStandardName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceStandardsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceStandardsClient) GetResponder(resp *http.Response) (result RegulatoryComplianceStandard, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List supported regulatory compliance standards details and state +// Parameters: +// filter - oData filter. Optional. +func (client RegulatoryComplianceStandardsClient) List(ctx context.Context, filter string) (result RegulatoryComplianceStandardListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardsClient.List") + defer func() { + sc := -1 + if result.rcsl.Response.Response != nil { + sc = result.rcsl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.RegulatoryComplianceStandardsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rcsl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "List", resp, "Failure sending request") + return + } + + result.rcsl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "List", resp, "Failure responding to request") + } + if result.rcsl.hasNextLink() && result.rcsl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client RegulatoryComplianceStandardsClient) ListPreparer(ctx context.Context, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client RegulatoryComplianceStandardsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RegulatoryComplianceStandardsClient) ListResponder(resp *http.Response) (result RegulatoryComplianceStandardList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client RegulatoryComplianceStandardsClient) listNextResults(ctx context.Context, lastResults RegulatoryComplianceStandardList) (result RegulatoryComplianceStandardList, err error) { + req, err := lastResults.regulatoryComplianceStandardListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.RegulatoryComplianceStandardsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client RegulatoryComplianceStandardsClient) ListComplete(ctx context.Context, filter string) (result RegulatoryComplianceStandardListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RegulatoryComplianceStandardsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, filter) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescorecontroldefinitions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescorecontroldefinitions.go new file mode 100644 index 0000000000000..ec41c4bb8a076 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescorecontroldefinitions.go @@ -0,0 +1,269 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SecureScoreControlDefinitionsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type SecureScoreControlDefinitionsClient struct { + BaseClient +} + +// NewSecureScoreControlDefinitionsClient creates an instance of the SecureScoreControlDefinitionsClient client. +func NewSecureScoreControlDefinitionsClient(subscriptionID string, ascLocation string) SecureScoreControlDefinitionsClient { + return NewSecureScoreControlDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewSecureScoreControlDefinitionsClientWithBaseURI creates an instance of the SecureScoreControlDefinitionsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewSecureScoreControlDefinitionsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) SecureScoreControlDefinitionsClient { + return SecureScoreControlDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// List list the available security controls, their assessments, and the max score +func (client SecureScoreControlDefinitionsClient) List(ctx context.Context) (result SecureScoreControlDefinitionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlDefinitionsClient.List") + defer func() { + sc := -1 + if result.sscdl.Response.Response != nil { + sc = result.sscdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sscdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "List", resp, "Failure sending request") + return + } + + result.sscdl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "List", resp, "Failure responding to request") + } + if result.sscdl.hasNextLink() && result.sscdl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client SecureScoreControlDefinitionsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Security/secureScoreControlDefinitions"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SecureScoreControlDefinitionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SecureScoreControlDefinitionsClient) ListResponder(resp *http.Response) (result SecureScoreControlDefinitionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SecureScoreControlDefinitionsClient) listNextResults(ctx context.Context, lastResults SecureScoreControlDefinitionList) (result SecureScoreControlDefinitionList, err error) { + req, err := lastResults.secureScoreControlDefinitionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SecureScoreControlDefinitionsClient) ListComplete(ctx context.Context) (result SecureScoreControlDefinitionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlDefinitionsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListBySubscription for a specified subscription, list the available security controls, their assessments, and the +// max score +func (client SecureScoreControlDefinitionsClient) ListBySubscription(ctx context.Context) (result SecureScoreControlDefinitionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlDefinitionsClient.ListBySubscription") + defer func() { + sc := -1 + if result.sscdl.Response.Response != nil { + sc = result.sscdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SecureScoreControlDefinitionsClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.sscdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.sscdl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "ListBySubscription", resp, "Failure responding to request") + } + if result.sscdl.hasNextLink() && result.sscdl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client SecureScoreControlDefinitionsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControlDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client SecureScoreControlDefinitionsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client SecureScoreControlDefinitionsClient) ListBySubscriptionResponder(resp *http.Response) (result SecureScoreControlDefinitionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client SecureScoreControlDefinitionsClient) listBySubscriptionNextResults(ctx context.Context, lastResults SecureScoreControlDefinitionList) (result SecureScoreControlDefinitionList, err error) { + req, err := lastResults.secureScoreControlDefinitionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlDefinitionsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client SecureScoreControlDefinitionsClient) ListBySubscriptionComplete(ctx context.Context) (result SecureScoreControlDefinitionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlDefinitionsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescorecontrols.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescorecontrols.go new file mode 100644 index 0000000000000..5b1ccb5acd6e8 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescorecontrols.go @@ -0,0 +1,291 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SecureScoreControlsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type SecureScoreControlsClient struct { + BaseClient +} + +// NewSecureScoreControlsClient creates an instance of the SecureScoreControlsClient client. +func NewSecureScoreControlsClient(subscriptionID string, ascLocation string) SecureScoreControlsClient { + return NewSecureScoreControlsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewSecureScoreControlsClientWithBaseURI creates an instance of the SecureScoreControlsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewSecureScoreControlsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) SecureScoreControlsClient { + return SecureScoreControlsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// List get all security controls within a scope +// Parameters: +// expand - oData expand. Optional. +func (client SecureScoreControlsClient) List(ctx context.Context, expand ExpandControlsEnum) (result SecureScoreControlListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlsClient.List") + defer func() { + sc := -1 + if result.sscl.Response.Response != nil { + sc = result.sscl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SecureScoreControlsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sscl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "List", resp, "Failure sending request") + return + } + + result.sscl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "List", resp, "Failure responding to request") + } + if result.sscl.hasNextLink() && result.sscl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client SecureScoreControlsClient) ListPreparer(ctx context.Context, expand ExpandControlsEnum) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(expand)) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControls", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SecureScoreControlsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SecureScoreControlsClient) ListResponder(resp *http.Response) (result SecureScoreControlList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SecureScoreControlsClient) listNextResults(ctx context.Context, lastResults SecureScoreControlList) (result SecureScoreControlList, err error) { + req, err := lastResults.secureScoreControlListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SecureScoreControlsClient) ListComplete(ctx context.Context, expand ExpandControlsEnum) (result SecureScoreControlListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, expand) + return +} + +// ListBySecureScore get all security controls for a specific initiative within a scope +// Parameters: +// secureScoreName - the initiative name. For the ASC Default initiative, use 'ascScore' as in the sample +// request below. +// expand - oData expand. Optional. +func (client SecureScoreControlsClient) ListBySecureScore(ctx context.Context, secureScoreName string, expand ExpandControlsEnum) (result SecureScoreControlListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlsClient.ListBySecureScore") + defer func() { + sc := -1 + if result.sscl.Response.Response != nil { + sc = result.sscl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SecureScoreControlsClient", "ListBySecureScore", err.Error()) + } + + result.fn = client.listBySecureScoreNextResults + req, err := client.ListBySecureScorePreparer(ctx, secureScoreName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "ListBySecureScore", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySecureScoreSender(req) + if err != nil { + result.sscl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "ListBySecureScore", resp, "Failure sending request") + return + } + + result.sscl, err = client.ListBySecureScoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "ListBySecureScore", resp, "Failure responding to request") + } + if result.sscl.hasNextLink() && result.sscl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListBySecureScorePreparer prepares the ListBySecureScore request. +func (client SecureScoreControlsClient) ListBySecureScorePreparer(ctx context.Context, secureScoreName string, expand ExpandControlsEnum) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "secureScoreName": autorest.Encode("path", secureScoreName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(expand)) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}/secureScoreControls", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySecureScoreSender sends the ListBySecureScore request. The method will close the +// http.Response Body if it receives an error. +func (client SecureScoreControlsClient) ListBySecureScoreSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySecureScoreResponder handles the response to the ListBySecureScore request. The method always +// closes the http.Response Body. +func (client SecureScoreControlsClient) ListBySecureScoreResponder(resp *http.Response) (result SecureScoreControlList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySecureScoreNextResults retrieves the next set of results, if any. +func (client SecureScoreControlsClient) listBySecureScoreNextResults(ctx context.Context, lastResults SecureScoreControlList) (result SecureScoreControlList, err error) { + req, err := lastResults.secureScoreControlListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "listBySecureScoreNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySecureScoreSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "listBySecureScoreNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySecureScoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoreControlsClient", "listBySecureScoreNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySecureScoreComplete enumerates all values, automatically crossing page boundaries as required. +func (client SecureScoreControlsClient) ListBySecureScoreComplete(ctx context.Context, secureScoreName string, expand ExpandControlsEnum) (result SecureScoreControlListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoreControlsClient.ListBySecureScore") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySecureScore(ctx, secureScoreName, expand) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescores.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescores.go new file mode 100644 index 0000000000000..1b2511acfa6a1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/securescores.go @@ -0,0 +1,241 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SecureScoresClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type SecureScoresClient struct { + BaseClient +} + +// NewSecureScoresClient creates an instance of the SecureScoresClient client. +func NewSecureScoresClient(subscriptionID string, ascLocation string) SecureScoresClient { + return NewSecureScoresClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewSecureScoresClientWithBaseURI creates an instance of the SecureScoresClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSecureScoresClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) SecureScoresClient { + return SecureScoresClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get secure score for a specific Security Center initiative within your current scope. For the ASC Default +// initiative, use 'ascScore'. +// Parameters: +// secureScoreName - the initiative name. For the ASC Default initiative, use 'ascScore' as in the sample +// request below. +func (client SecureScoresClient) Get(ctx context.Context, secureScoreName string) (result SecureScoreItem, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoresClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SecureScoresClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, secureScoreName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoresClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SecureScoresClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoresClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SecureScoresClient) GetPreparer(ctx context.Context, secureScoreName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "secureScoreName": autorest.Encode("path", secureScoreName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SecureScoresClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SecureScoresClient) GetResponder(resp *http.Response) (result SecureScoreItem, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list secure scores for all your Security Center initiatives within your current scope. +func (client SecureScoresClient) List(ctx context.Context) (result SecureScoresListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoresClient.List") + defer func() { + sc := -1 + if result.ssl.Response.Response != nil { + sc = result.ssl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SecureScoresClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoresClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ssl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SecureScoresClient", "List", resp, "Failure sending request") + return + } + + result.ssl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoresClient", "List", resp, "Failure responding to request") + } + if result.ssl.hasNextLink() && result.ssl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client SecureScoresClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SecureScoresClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SecureScoresClient) ListResponder(resp *http.Response) (result SecureScoresList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SecureScoresClient) listNextResults(ctx context.Context, lastResults SecureScoresList) (result SecureScoresList, err error) { + req, err := lastResults.secureScoresListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.SecureScoresClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.SecureScoresClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SecureScoresClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SecureScoresClient) ListComplete(ctx context.Context) (result SecureScoresListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecureScoresClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/servervulnerabilityassessment.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/servervulnerabilityassessment.go new file mode 100644 index 0000000000000..8d129aa5516e5 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/servervulnerabilityassessment.go @@ -0,0 +1,407 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerVulnerabilityAssessmentClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type ServerVulnerabilityAssessmentClient struct { + BaseClient +} + +// NewServerVulnerabilityAssessmentClient creates an instance of the ServerVulnerabilityAssessmentClient client. +func NewServerVulnerabilityAssessmentClient(subscriptionID string, ascLocation string) ServerVulnerabilityAssessmentClient { + return NewServerVulnerabilityAssessmentClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewServerVulnerabilityAssessmentClientWithBaseURI creates an instance of the ServerVulnerabilityAssessmentClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewServerVulnerabilityAssessmentClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) ServerVulnerabilityAssessmentClient { + return ServerVulnerabilityAssessmentClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// CreateOrUpdate creating a server vulnerability assessment on a resource, which will onboard a resource for having a +// vulnerability assessment on it +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +func (client ServerVulnerabilityAssessmentClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result ServerVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ServerVulnerabilityAssessmentClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerVulnerabilityAssessmentClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "serverVulnerabilityAssessment": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentClient) CreateOrUpdateResponder(resp *http.Response) (result ServerVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removing server vulnerability assessment from a resource. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +func (client ServerVulnerabilityAssessmentClient) Delete(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ServerVulnerabilityAssessmentClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerVulnerabilityAssessmentClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "serverVulnerabilityAssessment": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server vulnerability assessment onboarding statuses on a given resource. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +func (client ServerVulnerabilityAssessmentClient) Get(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result ServerVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ServerVulnerabilityAssessmentClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerVulnerabilityAssessmentClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "serverVulnerabilityAssessment": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentClient) GetResponder(resp *http.Response) (result ServerVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByExtendedResource gets a list of server vulnerability assessment onboarding statuses on a given resource. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// resourceNamespace - the Namespace of the resource. +// resourceType - the type of the resource. +// resourceName - name of the resource. +func (client ServerVulnerabilityAssessmentClient) ListByExtendedResource(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (result ServerVulnerabilityAssessmentsList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentClient.ListByExtendedResource") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.ServerVulnerabilityAssessmentClient", "ListByExtendedResource", err.Error()) + } + + req, err := client.ListByExtendedResourcePreparer(ctx, resourceGroupName, resourceNamespace, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "ListByExtendedResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListByExtendedResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "ListByExtendedResource", resp, "Failure sending request") + return + } + + result, err = client.ListByExtendedResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.ServerVulnerabilityAssessmentClient", "ListByExtendedResource", resp, "Failure responding to request") + } + + return +} + +// ListByExtendedResourcePreparer prepares the ListByExtendedResource request. +func (client ServerVulnerabilityAssessmentClient) ListByExtendedResourcePreparer(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceNamespace": autorest.Encode("path", resourceNamespace), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByExtendedResourceSender sends the ListByExtendedResource request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentClient) ListByExtendedResourceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByExtendedResourceResponder handles the response to the ListByExtendedResource request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentClient) ListByExtendedResourceResponder(resp *http.Response) (result ServerVulnerabilityAssessmentsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/settings.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/settings.go new file mode 100644 index 0000000000000..9098f08e3e2eb --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/settings.go @@ -0,0 +1,321 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SettingsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type SettingsClient struct { + BaseClient +} + +// NewSettingsClient creates an instance of the SettingsClient client. +func NewSettingsClient(subscriptionID string, ascLocation string) SettingsClient { + return NewSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewSettingsClientWithBaseURI creates an instance of the SettingsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSettingsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) SettingsClient { + return SettingsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get settings of different configurations in security center +// Parameters: +// settingName - name of setting: (MCAS/WDATP) +func (client SettingsClient) Get(ctx context.Context, settingName string) (result Setting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, settingName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SettingsClient) GetPreparer(ctx context.Context, settingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "settingName": autorest.Encode("path", settingName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SettingsClient) GetResponder(resp *http.Response) (result Setting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List settings about different configurations in security center +func (client SettingsClient) List(ctx context.Context) (result SettingsListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SettingsClient.List") + defer func() { + sc := -1 + if result.sl.Response.Response != nil { + sc = result.sl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SettingsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SettingsClient", "List", resp, "Failure sending request") + return + } + + result.sl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "List", resp, "Failure responding to request") + } + if result.sl.hasNextLink() && result.sl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client SettingsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SettingsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SettingsClient) ListResponder(resp *http.Response) (result SettingsList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SettingsClient) listNextResults(ctx context.Context, lastResults SettingsList) (result SettingsList, err error) { + req, err := lastResults.settingsListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.SettingsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.SettingsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SettingsClient) ListComplete(ctx context.Context) (result SettingsListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SettingsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// Update updating settings about different configurations in security center +// Parameters: +// settingName - name of setting: (MCAS/WDATP) +// setting - setting object +func (client SettingsClient) Update(ctx context.Context, settingName string, setting BasicSetting) (result Setting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SettingsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SettingsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, settingName, setting) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SettingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SettingsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SettingsClient) UpdatePreparer(ctx context.Context, settingName string, setting BasicSetting) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "settingName": autorest.Encode("path", settingName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}", pathParameters), + autorest.WithJSON(setting), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SettingsClient) UpdateResponder(resp *http.Response) (result Setting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/solutions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/solutions.go new file mode 100644 index 0000000000000..5bdfd2a4b952a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/solutions.go @@ -0,0 +1,247 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SolutionsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type SolutionsClient struct { + BaseClient +} + +// NewSolutionsClient creates an instance of the SolutionsClient client. +func NewSolutionsClient(subscriptionID string, ascLocation string) SolutionsClient { + return NewSolutionsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewSolutionsClientWithBaseURI creates an instance of the SolutionsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSolutionsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) SolutionsClient { + return SolutionsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get gets a specific Security Solution. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// securitySolutionName - name of security solution. +func (client SolutionsClient) Get(ctx context.Context, resourceGroupName string, securitySolutionName string) (result Solution, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SolutionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, securitySolutionName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SolutionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SolutionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SolutionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SolutionsClient) GetPreparer(ctx context.Context, resourceGroupName string, securitySolutionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securitySolutionName": autorest.Encode("path", securitySolutionName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutions/{securitySolutionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SolutionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SolutionsClient) GetResponder(resp *http.Response) (result Solution, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of Security Solutions for the subscription. +func (client SolutionsClient) List(ctx context.Context) (result SolutionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsClient.List") + defer func() { + sc := -1 + if result.sl.Response.Response != nil { + sc = result.sl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SolutionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SolutionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SolutionsClient", "List", resp, "Failure sending request") + return + } + + result.sl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SolutionsClient", "List", resp, "Failure responding to request") + } + if result.sl.hasNextLink() && result.sl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client SolutionsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SolutionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SolutionsClient) ListResponder(resp *http.Response) (result SolutionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SolutionsClient) listNextResults(ctx context.Context, lastResults SolutionList) (result SolutionList, err error) { + req, err := lastResults.solutionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.SolutionsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.SolutionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SolutionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SolutionsClient) ListComplete(ctx context.Context) (result SolutionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/solutionsreferencedata.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/solutionsreferencedata.go new file mode 100644 index 0000000000000..a1a371c454a42 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/solutionsreferencedata.go @@ -0,0 +1,197 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SolutionsReferenceDataClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type SolutionsReferenceDataClient struct { + BaseClient +} + +// NewSolutionsReferenceDataClient creates an instance of the SolutionsReferenceDataClient client. +func NewSolutionsReferenceDataClient(subscriptionID string, ascLocation string) SolutionsReferenceDataClient { + return NewSolutionsReferenceDataClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewSolutionsReferenceDataClientWithBaseURI creates an instance of the SolutionsReferenceDataClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewSolutionsReferenceDataClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) SolutionsReferenceDataClient { + return SolutionsReferenceDataClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// List gets a list of all supported Security Solutions for the subscription. +func (client SolutionsReferenceDataClient) List(ctx context.Context) (result SolutionsReferenceDataList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsReferenceDataClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SolutionsReferenceDataClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SolutionsReferenceDataClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SolutionsReferenceDataClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SolutionsReferenceDataClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SolutionsReferenceDataClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutionsReferenceData", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SolutionsReferenceDataClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SolutionsReferenceDataClient) ListResponder(resp *http.Response) (result SolutionsReferenceDataList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByHomeRegion gets list of all supported Security Solutions for subscription and location. +func (client SolutionsReferenceDataClient) ListByHomeRegion(ctx context.Context) (result SolutionsReferenceDataList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsReferenceDataClient.ListByHomeRegion") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.SolutionsReferenceDataClient", "ListByHomeRegion", err.Error()) + } + + req, err := client.ListByHomeRegionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SolutionsReferenceDataClient", "ListByHomeRegion", nil, "Failure preparing request") + return + } + + resp, err := client.ListByHomeRegionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SolutionsReferenceDataClient", "ListByHomeRegion", resp, "Failure sending request") + return + } + + result, err = client.ListByHomeRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SolutionsReferenceDataClient", "ListByHomeRegion", resp, "Failure responding to request") + } + + return +} + +// ListByHomeRegionPreparer prepares the ListByHomeRegion request. +func (client SolutionsReferenceDataClient) ListByHomeRegionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutionsReferenceData", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByHomeRegionSender sends the ListByHomeRegion request. The method will close the +// http.Response Body if it receives an error. +func (client SolutionsReferenceDataClient) ListByHomeRegionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByHomeRegionResponder handles the response to the ListByHomeRegion request. The method always +// closes the http.Response Body. +func (client SolutionsReferenceDataClient) ListByHomeRegionResponder(resp *http.Response) (result SolutionsReferenceDataList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/subassessments.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/subassessments.go new file mode 100644 index 0000000000000..dcb46b74ca9dd --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/subassessments.go @@ -0,0 +1,349 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SubAssessmentsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type SubAssessmentsClient struct { + BaseClient +} + +// NewSubAssessmentsClient creates an instance of the SubAssessmentsClient client. +func NewSubAssessmentsClient(subscriptionID string, ascLocation string) SubAssessmentsClient { + return NewSubAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewSubAssessmentsClientWithBaseURI creates an instance of the SubAssessmentsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSubAssessmentsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) SubAssessmentsClient { + return SubAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get get a security sub-assessment on your scanned resource +// Parameters: +// scope - scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or +// management group (/providers/Microsoft.Management/managementGroups/mgName). +// assessmentName - the Assessment Key - Unique key for the assessment type +// subAssessmentName - the Sub-Assessment Key - Unique key for the sub-assessment type +func (client SubAssessmentsClient) Get(ctx context.Context, scope string, assessmentName string, subAssessmentName string) (result SubAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, scope, assessmentName, subAssessmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SubAssessmentsClient) GetPreparer(ctx context.Context, scope string, assessmentName string, subAssessmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentName": autorest.Encode("path", assessmentName), + "scope": scope, + "subAssessmentName": autorest.Encode("path", subAssessmentName), + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments/{subAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SubAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SubAssessmentsClient) GetResponder(resp *http.Response) (result SubAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get security sub-assessments on all your scanned resources inside a scope +// Parameters: +// scope - scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or +// management group (/providers/Microsoft.Management/managementGroups/mgName). +// assessmentName - the Assessment Key - Unique key for the assessment type +func (client SubAssessmentsClient) List(ctx context.Context, scope string, assessmentName string) (result SubAssessmentListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubAssessmentsClient.List") + defer func() { + sc := -1 + if result.sal.Response.Response != nil { + sc = result.sal.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, scope, assessmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sal.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "List", resp, "Failure sending request") + return + } + + result.sal, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "List", resp, "Failure responding to request") + } + if result.sal.hasNextLink() && result.sal.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client SubAssessmentsClient) ListPreparer(ctx context.Context, scope string, assessmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "assessmentName": autorest.Encode("path", assessmentName), + "scope": scope, + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SubAssessmentsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SubAssessmentsClient) ListResponder(resp *http.Response) (result SubAssessmentList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SubAssessmentsClient) listNextResults(ctx context.Context, lastResults SubAssessmentList) (result SubAssessmentList, err error) { + req, err := lastResults.subAssessmentListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubAssessmentsClient) ListComplete(ctx context.Context, scope string, assessmentName string) (result SubAssessmentListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubAssessmentsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, scope, assessmentName) + return +} + +// ListAll get security sub-assessments on all your scanned resources inside a subscription scope +// Parameters: +// scope - scope of the query, can be subscription (/subscriptions/0b06d9ea-afe6-4779-bd59-30e5c2d9d13f) or +// management group (/providers/Microsoft.Management/managementGroups/mgName). +func (client SubAssessmentsClient) ListAll(ctx context.Context, scope string) (result SubAssessmentListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubAssessmentsClient.ListAll") + defer func() { + sc := -1 + if result.sal.Response.Response != nil { + sc = result.sal.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listAllNextResults + req, err := client.ListAllPreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "ListAll", nil, "Failure preparing request") + return + } + + resp, err := client.ListAllSender(req) + if err != nil { + result.sal.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "ListAll", resp, "Failure sending request") + return + } + + result.sal, err = client.ListAllResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "ListAll", resp, "Failure responding to request") + } + if result.sal.hasNextLink() && result.sal.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListAllPreparer prepares the ListAll request. +func (client SubAssessmentsClient) ListAllPreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2019-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.Security/subAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListAllSender sends the ListAll request. The method will close the +// http.Response Body if it receives an error. +func (client SubAssessmentsClient) ListAllSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListAllResponder handles the response to the ListAll request. The method always +// closes the http.Response Body. +func (client SubAssessmentsClient) ListAllResponder(resp *http.Response) (result SubAssessmentList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listAllNextResults retrieves the next set of results, if any. +func (client SubAssessmentsClient) listAllNextResults(ctx context.Context, lastResults SubAssessmentList) (result SubAssessmentList, err error) { + req, err := lastResults.subAssessmentListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "listAllNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListAllSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "listAllNextResults", resp, "Failure sending next results request") + } + result, err = client.ListAllResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.SubAssessmentsClient", "listAllNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListAllComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubAssessmentsClient) ListAllComplete(ctx context.Context, scope string) (result SubAssessmentListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubAssessmentsClient.ListAll") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListAll(ctx, scope) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/tasks.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/tasks.go new file mode 100644 index 0000000000000..34d8790bd7c75 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/tasks.go @@ -0,0 +1,756 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TasksClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type TasksClient struct { + BaseClient +} + +// NewTasksClient creates an instance of the TasksClient client. +func NewTasksClient(subscriptionID string, ascLocation string) TasksClient { + return NewTasksClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewTasksClientWithBaseURI creates an instance of the TasksClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTasksClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) TasksClient { + return TasksClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// GetResourceGroupLevelTask recommended tasks that will help improve the security of the subscription proactively +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// taskName - name of the task object, will be a GUID +func (client TasksClient) GetResourceGroupLevelTask(ctx context.Context, resourceGroupName string, taskName string) (result Task, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TasksClient.GetResourceGroupLevelTask") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.TasksClient", "GetResourceGroupLevelTask", err.Error()) + } + + req, err := client.GetResourceGroupLevelTaskPreparer(ctx, resourceGroupName, taskName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "GetResourceGroupLevelTask", nil, "Failure preparing request") + return + } + + resp, err := client.GetResourceGroupLevelTaskSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.TasksClient", "GetResourceGroupLevelTask", resp, "Failure sending request") + return + } + + result, err = client.GetResourceGroupLevelTaskResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "GetResourceGroupLevelTask", resp, "Failure responding to request") + } + + return +} + +// GetResourceGroupLevelTaskPreparer prepares the GetResourceGroupLevelTask request. +func (client TasksClient) GetResourceGroupLevelTaskPreparer(ctx context.Context, resourceGroupName string, taskName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "taskName": autorest.Encode("path", taskName), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetResourceGroupLevelTaskSender sends the GetResourceGroupLevelTask request. The method will close the +// http.Response Body if it receives an error. +func (client TasksClient) GetResourceGroupLevelTaskSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResourceGroupLevelTaskResponder handles the response to the GetResourceGroupLevelTask request. The method always +// closes the http.Response Body. +func (client TasksClient) GetResourceGroupLevelTaskResponder(resp *http.Response) (result Task, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSubscriptionLevelTask recommended tasks that will help improve the security of the subscription proactively +// Parameters: +// taskName - name of the task object, will be a GUID +func (client TasksClient) GetSubscriptionLevelTask(ctx context.Context, taskName string) (result Task, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TasksClient.GetSubscriptionLevelTask") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.TasksClient", "GetSubscriptionLevelTask", err.Error()) + } + + req, err := client.GetSubscriptionLevelTaskPreparer(ctx, taskName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "GetSubscriptionLevelTask", nil, "Failure preparing request") + return + } + + resp, err := client.GetSubscriptionLevelTaskSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.TasksClient", "GetSubscriptionLevelTask", resp, "Failure sending request") + return + } + + result, err = client.GetSubscriptionLevelTaskResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "GetSubscriptionLevelTask", resp, "Failure responding to request") + } + + return +} + +// GetSubscriptionLevelTaskPreparer prepares the GetSubscriptionLevelTask request. +func (client TasksClient) GetSubscriptionLevelTaskPreparer(ctx context.Context, taskName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "taskName": autorest.Encode("path", taskName), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSubscriptionLevelTaskSender sends the GetSubscriptionLevelTask request. The method will close the +// http.Response Body if it receives an error. +func (client TasksClient) GetSubscriptionLevelTaskSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSubscriptionLevelTaskResponder handles the response to the GetSubscriptionLevelTask request. The method always +// closes the http.Response Body. +func (client TasksClient) GetSubscriptionLevelTaskResponder(resp *http.Response) (result Task, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List recommended tasks that will help improve the security of the subscription proactively +// Parameters: +// filter - oData filter. Optional. +func (client TasksClient) List(ctx context.Context, filter string) (result TaskListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TasksClient.List") + defer func() { + sc := -1 + if result.tl.Response.Response != nil { + sc = result.tl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.TasksClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.tl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.TasksClient", "List", resp, "Failure sending request") + return + } + + result.tl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "List", resp, "Failure responding to request") + } + if result.tl.hasNextLink() && result.tl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client TasksClient) ListPreparer(ctx context.Context, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/tasks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client TasksClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client TasksClient) ListResponder(resp *http.Response) (result TaskList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client TasksClient) listNextResults(ctx context.Context, lastResults TaskList) (result TaskList, err error) { + req, err := lastResults.taskListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.TasksClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.TasksClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client TasksClient) ListComplete(ctx context.Context, filter string) (result TaskListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TasksClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, filter) + return +} + +// ListByHomeRegion recommended tasks that will help improve the security of the subscription proactively +// Parameters: +// filter - oData filter. Optional. +func (client TasksClient) ListByHomeRegion(ctx context.Context, filter string) (result TaskListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TasksClient.ListByHomeRegion") + defer func() { + sc := -1 + if result.tl.Response.Response != nil { + sc = result.tl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.TasksClient", "ListByHomeRegion", err.Error()) + } + + result.fn = client.listByHomeRegionNextResults + req, err := client.ListByHomeRegionPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "ListByHomeRegion", nil, "Failure preparing request") + return + } + + resp, err := client.ListByHomeRegionSender(req) + if err != nil { + result.tl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.TasksClient", "ListByHomeRegion", resp, "Failure sending request") + return + } + + result.tl, err = client.ListByHomeRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "ListByHomeRegion", resp, "Failure responding to request") + } + if result.tl.hasNextLink() && result.tl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByHomeRegionPreparer prepares the ListByHomeRegion request. +func (client TasksClient) ListByHomeRegionPreparer(ctx context.Context, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByHomeRegionSender sends the ListByHomeRegion request. The method will close the +// http.Response Body if it receives an error. +func (client TasksClient) ListByHomeRegionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByHomeRegionResponder handles the response to the ListByHomeRegion request. The method always +// closes the http.Response Body. +func (client TasksClient) ListByHomeRegionResponder(resp *http.Response) (result TaskList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByHomeRegionNextResults retrieves the next set of results, if any. +func (client TasksClient) listByHomeRegionNextResults(ctx context.Context, lastResults TaskList) (result TaskList, err error) { + req, err := lastResults.taskListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.TasksClient", "listByHomeRegionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByHomeRegionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.TasksClient", "listByHomeRegionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByHomeRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "listByHomeRegionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByHomeRegionComplete enumerates all values, automatically crossing page boundaries as required. +func (client TasksClient) ListByHomeRegionComplete(ctx context.Context, filter string) (result TaskListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TasksClient.ListByHomeRegion") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByHomeRegion(ctx, filter) + return +} + +// ListByResourceGroup recommended tasks that will help improve the security of the subscription proactively +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// filter - oData filter. Optional. +func (client TasksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result TaskListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TasksClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.tl.Response.Response != nil { + sc = result.tl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.TasksClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.tl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.TasksClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.tl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.tl.hasNextLink() && result.tl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client TasksClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client TasksClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client TasksClient) ListByResourceGroupResponder(resp *http.Response) (result TaskList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client TasksClient) listByResourceGroupNextResults(ctx context.Context, lastResults TaskList) (result TaskList, err error) { + req, err := lastResults.taskListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.TasksClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.TasksClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client TasksClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string) (result TaskListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TasksClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter) + return +} + +// UpdateResourceGroupLevelTaskState recommended tasks that will help improve the security of the subscription +// proactively +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// taskName - name of the task object, will be a GUID +// taskUpdateActionType - type of the action to do on the task +func (client TasksClient) UpdateResourceGroupLevelTaskState(ctx context.Context, resourceGroupName string, taskName string, taskUpdateActionType string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TasksClient.UpdateResourceGroupLevelTaskState") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.TasksClient", "UpdateResourceGroupLevelTaskState", err.Error()) + } + + req, err := client.UpdateResourceGroupLevelTaskStatePreparer(ctx, resourceGroupName, taskName, taskUpdateActionType) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "UpdateResourceGroupLevelTaskState", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateResourceGroupLevelTaskStateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.TasksClient", "UpdateResourceGroupLevelTaskState", resp, "Failure sending request") + return + } + + result, err = client.UpdateResourceGroupLevelTaskStateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "UpdateResourceGroupLevelTaskState", resp, "Failure responding to request") + } + + return +} + +// UpdateResourceGroupLevelTaskStatePreparer prepares the UpdateResourceGroupLevelTaskState request. +func (client TasksClient) UpdateResourceGroupLevelTaskStatePreparer(ctx context.Context, resourceGroupName string, taskName string, taskUpdateActionType string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "taskName": autorest.Encode("path", taskName), + "taskUpdateActionType": autorest.Encode("path", taskUpdateActionType), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateResourceGroupLevelTaskStateSender sends the UpdateResourceGroupLevelTaskState request. The method will close the +// http.Response Body if it receives an error. +func (client TasksClient) UpdateResourceGroupLevelTaskStateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResourceGroupLevelTaskStateResponder handles the response to the UpdateResourceGroupLevelTaskState request. The method always +// closes the http.Response Body. +func (client TasksClient) UpdateResourceGroupLevelTaskStateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateSubscriptionLevelTaskState recommended tasks that will help improve the security of the subscription +// proactively +// Parameters: +// taskName - name of the task object, will be a GUID +// taskUpdateActionType - type of the action to do on the task +func (client TasksClient) UpdateSubscriptionLevelTaskState(ctx context.Context, taskName string, taskUpdateActionType string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TasksClient.UpdateSubscriptionLevelTaskState") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.TasksClient", "UpdateSubscriptionLevelTaskState", err.Error()) + } + + req, err := client.UpdateSubscriptionLevelTaskStatePreparer(ctx, taskName, taskUpdateActionType) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "UpdateSubscriptionLevelTaskState", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSubscriptionLevelTaskStateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.TasksClient", "UpdateSubscriptionLevelTaskState", resp, "Failure sending request") + return + } + + result, err = client.UpdateSubscriptionLevelTaskStateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TasksClient", "UpdateSubscriptionLevelTaskState", resp, "Failure responding to request") + } + + return +} + +// UpdateSubscriptionLevelTaskStatePreparer prepares the UpdateSubscriptionLevelTaskState request. +func (client TasksClient) UpdateSubscriptionLevelTaskStatePreparer(ctx context.Context, taskName string, taskUpdateActionType string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "taskName": autorest.Encode("path", taskName), + "taskUpdateActionType": autorest.Encode("path", taskUpdateActionType), + } + + const APIVersion = "2015-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSubscriptionLevelTaskStateSender sends the UpdateSubscriptionLevelTaskState request. The method will close the +// http.Response Body if it receives an error. +func (client TasksClient) UpdateSubscriptionLevelTaskStateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateSubscriptionLevelTaskStateResponder handles the response to the UpdateSubscriptionLevelTaskState request. The method always +// closes the http.Response Body. +func (client TasksClient) UpdateSubscriptionLevelTaskStateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/topology.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/topology.go new file mode 100644 index 0000000000000..e2f1936480533 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/topology.go @@ -0,0 +1,365 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TopologyClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type TopologyClient struct { + BaseClient +} + +// NewTopologyClient creates an instance of the TopologyClient client. +func NewTopologyClient(subscriptionID string, ascLocation string) TopologyClient { + return NewTopologyClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewTopologyClientWithBaseURI creates an instance of the TopologyClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTopologyClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) TopologyClient { + return TopologyClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Get gets a specific topology component. +// Parameters: +// resourceGroupName - the name of the resource group within the user's subscription. The name is case +// insensitive. +// topologyResourceName - name of a topology resources collection. +func (client TopologyClient) Get(ctx context.Context, resourceGroupName string, topologyResourceName string) (result TopologyResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopologyClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.TopologyClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, topologyResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TopologyClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.TopologyClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TopologyClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TopologyClient) GetPreparer(ctx context.Context, resourceGroupName string, topologyResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "topologyResourceName": autorest.Encode("path", topologyResourceName), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/topologies/{topologyResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TopologyClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TopologyClient) GetResponder(resp *http.Response) (result TopologyResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list that allows to build a topology view of a subscription. +func (client TopologyClient) List(ctx context.Context) (result TopologyListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopologyClient.List") + defer func() { + sc := -1 + if result.tl.Response.Response != nil { + sc = result.tl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.TopologyClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TopologyClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.tl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.TopologyClient", "List", resp, "Failure sending request") + return + } + + result.tl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TopologyClient", "List", resp, "Failure responding to request") + } + if result.tl.hasNextLink() && result.tl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client TopologyClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/topologies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client TopologyClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client TopologyClient) ListResponder(resp *http.Response) (result TopologyList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client TopologyClient) listNextResults(ctx context.Context, lastResults TopologyList) (result TopologyList, err error) { + req, err := lastResults.topologyListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.TopologyClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.TopologyClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TopologyClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client TopologyClient) ListComplete(ctx context.Context) (result TopologyListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopologyClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByHomeRegion gets a list that allows to build a topology view of a subscription and location. +func (client TopologyClient) ListByHomeRegion(ctx context.Context) (result TopologyListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopologyClient.ListByHomeRegion") + defer func() { + sc := -1 + if result.tl.Response.Response != nil { + sc = result.tl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.TopologyClient", "ListByHomeRegion", err.Error()) + } + + result.fn = client.listByHomeRegionNextResults + req, err := client.ListByHomeRegionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TopologyClient", "ListByHomeRegion", nil, "Failure preparing request") + return + } + + resp, err := client.ListByHomeRegionSender(req) + if err != nil { + result.tl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.TopologyClient", "ListByHomeRegion", resp, "Failure sending request") + return + } + + result.tl, err = client.ListByHomeRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TopologyClient", "ListByHomeRegion", resp, "Failure responding to request") + } + if result.tl.hasNextLink() && result.tl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByHomeRegionPreparer prepares the ListByHomeRegion request. +func (client TopologyClient) ListByHomeRegionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ascLocation": autorest.Encode("path", client.AscLocation), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/topologies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByHomeRegionSender sends the ListByHomeRegion request. The method will close the +// http.Response Body if it receives an error. +func (client TopologyClient) ListByHomeRegionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByHomeRegionResponder handles the response to the ListByHomeRegion request. The method always +// closes the http.Response Body. +func (client TopologyClient) ListByHomeRegionResponder(resp *http.Response) (result TopologyList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByHomeRegionNextResults retrieves the next set of results, if any. +func (client TopologyClient) listByHomeRegionNextResults(ctx context.Context, lastResults TopologyList) (result TopologyList, err error) { + req, err := lastResults.topologyListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.TopologyClient", "listByHomeRegionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByHomeRegionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.TopologyClient", "listByHomeRegionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByHomeRegionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.TopologyClient", "listByHomeRegionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByHomeRegionComplete enumerates all values, automatically crossing page boundaries as required. +func (client TopologyClient) ListByHomeRegionComplete(ctx context.Context) (result TopologyListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopologyClient.ListByHomeRegion") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByHomeRegion(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/version.go new file mode 100644 index 0000000000000..9ef7c97c91a02 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/version.go @@ -0,0 +1,30 @@ +package security + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " security/v3.0" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/workspacesettings.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/workspacesettings.go new file mode 100644 index 0000000000000..9eb533d2e6384 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security/workspacesettings.go @@ -0,0 +1,489 @@ +package security + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WorkspaceSettingsClient is the API spec for Microsoft.Security (Azure Security Center) resource provider +type WorkspaceSettingsClient struct { + BaseClient +} + +// NewWorkspaceSettingsClient creates an instance of the WorkspaceSettingsClient client. +func NewWorkspaceSettingsClient(subscriptionID string, ascLocation string) WorkspaceSettingsClient { + return NewWorkspaceSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID, ascLocation) +} + +// NewWorkspaceSettingsClientWithBaseURI creates an instance of the WorkspaceSettingsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewWorkspaceSettingsClientWithBaseURI(baseURI string, subscriptionID string, ascLocation string) WorkspaceSettingsClient { + return WorkspaceSettingsClient{NewWithBaseURI(baseURI, subscriptionID, ascLocation)} +} + +// Create creating settings about where we should store your security data and logs +// Parameters: +// workspaceSettingName - name of the security setting +// workspaceSetting - security data setting object +func (client WorkspaceSettingsClient) Create(ctx context.Context, workspaceSettingName string, workspaceSetting WorkspaceSetting) (result WorkspaceSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceSettingsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}, + {TargetValue: workspaceSetting, + Constraints: []validation.Constraint{{Target: "workspaceSetting.WorkspaceSettingProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "workspaceSetting.WorkspaceSettingProperties.WorkspaceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "workspaceSetting.WorkspaceSettingProperties.Scope", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("security.WorkspaceSettingsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, workspaceSettingName, workspaceSetting) + if err != nil { + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client WorkspaceSettingsClient) CreatePreparer(ctx context.Context, workspaceSettingName string, workspaceSetting WorkspaceSetting) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceSettingName": autorest.Encode("path", workspaceSettingName), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", pathParameters), + autorest.WithJSON(workspaceSetting), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspaceSettingsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client WorkspaceSettingsClient) CreateResponder(resp *http.Response) (result WorkspaceSetting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the custom workspace settings for this subscription. new VMs will report to the default workspace +// Parameters: +// workspaceSettingName - name of the security setting +func (client WorkspaceSettingsClient) Delete(ctx context.Context, workspaceSettingName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceSettingsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.WorkspaceSettingsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, workspaceSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkspaceSettingsClient) DeletePreparer(ctx context.Context, workspaceSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceSettingName": autorest.Encode("path", workspaceSettingName), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspaceSettingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkspaceSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get settings about where we should store your security data and logs. If the result is empty, it means that no +// custom-workspace configuration was set +// Parameters: +// workspaceSettingName - name of the security setting +func (client WorkspaceSettingsClient) Get(ctx context.Context, workspaceSettingName string) (result WorkspaceSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.WorkspaceSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, workspaceSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkspaceSettingsClient) GetPreparer(ctx context.Context, workspaceSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceSettingName": autorest.Encode("path", workspaceSettingName), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspaceSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkspaceSettingsClient) GetResponder(resp *http.Response) (result WorkspaceSetting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List settings about where we should store your security data and logs. If the result is empty, it means that no +// custom-workspace configuration was set +func (client WorkspaceSettingsClient) List(ctx context.Context) (result WorkspaceSettingListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceSettingsClient.List") + defer func() { + sc := -1 + if result.wsl.Response.Response != nil { + sc = result.wsl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.WorkspaceSettingsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.wsl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "List", resp, "Failure sending request") + return + } + + result.wsl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "List", resp, "Failure responding to request") + } + if result.wsl.hasNextLink() && result.wsl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client WorkspaceSettingsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspaceSettingsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client WorkspaceSettingsClient) ListResponder(resp *http.Response) (result WorkspaceSettingList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client WorkspaceSettingsClient) listNextResults(ctx context.Context, lastResults WorkspaceSettingList) (result WorkspaceSettingList, err error) { + req, err := lastResults.workspaceSettingListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkspaceSettingsClient) ListComplete(ctx context.Context) (result WorkspaceSettingListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceSettingsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// Update settings about where we should store your security data and logs +// Parameters: +// workspaceSettingName - name of the security setting +// workspaceSetting - security data setting object +func (client WorkspaceSettingsClient) Update(ctx context.Context, workspaceSettingName string, workspaceSetting WorkspaceSetting) (result WorkspaceSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceSettingsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("security.WorkspaceSettingsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, workspaceSettingName, workspaceSetting) + if err != nil { + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "security.WorkspaceSettingsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WorkspaceSettingsClient) UpdatePreparer(ctx context.Context, workspaceSettingName string, workspaceSetting WorkspaceSetting) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceSettingName": autorest.Encode("path", workspaceSettingName), + } + + const APIVersion = "2017-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}", pathParameters), + autorest.WithJSON(workspaceSetting), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspaceSettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WorkspaceSettingsClient) UpdateResponder(resp *http.Response) (result WorkspaceSetting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 1d8b9695451ed..76d54dc4f58ff 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -76,6 +76,7 @@ github.com/Azure/azure-sdk-for-go/services/preview/operationsmanagement/mgmt/201 github.com/Azure/azure-sdk-for-go/services/preview/portal/mgmt/2019-01-01-preview/portal github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-03-01-preview/managementgroups github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v1.0/security +github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security github.com/Azure/azure-sdk-for-go/services/preview/securityinsight/mgmt/2019-01-01-preview/securityinsight github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2018-01-01-preview/servicebus github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql diff --git a/website/docs/r/security_center_subscription_pricing.markdown b/website/docs/r/security_center_subscription_pricing.markdown index f63c2ef3c15a2..b96122d7ffe95 100644 --- a/website/docs/r/security_center_subscription_pricing.markdown +++ b/website/docs/r/security_center_subscription_pricing.markdown @@ -19,6 +19,7 @@ Manages the Pricing Tier for Azure Security Center in the current subscription. ```hcl resource "azurerm_security_center_subscription_pricing" "example" { tier = "Standard" + resource_type = "VirtualMachines" } ``` @@ -27,8 +28,9 @@ resource "azurerm_security_center_subscription_pricing" "example" { The following arguments are supported: * `tier` - (Required) The pricing tier to use. Possible values are `Free` and `Standard`. +* `resource_type` - (Required) The resource type this setting affects. Possible values are `AppServices`, `ContainerRegistry`, `KeyVaults`, `KubernetesService`, `SqlServers`, `SqlServerVirtualMachines`, `StorageAccounts`, and `VirtualMachines`. -~> **NOTE:** Changing the pricing tier to `Standard` affects all resources in the subscription and could be quite costly. +~> **NOTE:** Changing the pricing tier to `Standard` affects all resources of the given type in the subscription and could be quite costly. ## Attributes Reference @@ -50,5 +52,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d The pricing tier can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_security_center_subscription_pricing.example /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Security/pricings/default +terraform import azurerm_security_center_subscription_pricing.example /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Security/pricings/ ```