From 46ea17fcd0a4cdeffd82560cb3267b5418994cf2 Mon Sep 17 00:00:00 2001 From: Alex Wilcox Date: Mon, 11 Dec 2023 14:04:48 +0000 Subject: [PATCH] Migrate to go-azure-sdk for security_center_automation --- .../services/securitycenter/client/client.go | 5 +- .../security_center_automation_resource.go | 189 +++++++++--------- ...ecurity_center_automation_resource_test.go | 6 +- .../2019-01-01-preview/automations/README.md | 128 ++++++++++++ .../2019-01-01-preview/automations/client.go | 18 ++ .../automations/constants.go | 175 ++++++++++++++++ .../automations/id_automation.go | 125 ++++++++++++ .../method_createorupdate_autorest.go | 69 +++++++ .../automations/method_delete_autorest.go | 66 ++++++ .../automations/method_get_autorest.go | 68 +++++++ .../automations/method_list_autorest.go | 187 +++++++++++++++++ .../method_listbyresourcegroup_autorest.go | 187 +++++++++++++++++ .../automations/method_validate_autorest.go | 70 +++++++ .../automations/model_automation.go | 15 ++ .../automations/model_automationaction.go | 69 +++++++ .../model_automationactioneventhub.go | 43 ++++ .../model_automationactionlogicapp.go | 42 ++++ .../model_automationactionworkspace.go | 41 ++++ .../automations/model_automationproperties.go | 55 +++++ .../automations/model_automationruleset.go | 8 + .../automations/model_automationscope.go | 9 + .../automations/model_automationsource.go | 9 + .../model_automationtriggeringrule.go | 11 + .../model_automationvalidationstatus.go | 9 + .../automations/predicates.go | 42 ++++ .../2019-01-01-preview/automations/version.go | 12 ++ vendor/modules.txt | 1 + 27 files changed, 1563 insertions(+), 96 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/id_automation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_createorupdate_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_delete_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_get_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_list_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_listbyresourcegroup_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_validate_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationaction.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactioneventhub.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactionlogicapp.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactionworkspace.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationruleset.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationscope.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationsource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationtriggeringrule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationvalidationstatus.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/version.go diff --git a/internal/services/securitycenter/client/client.go b/internal/services/securitycenter/client/client.go index 9835e463f615..d8a68af3404c 100644 --- a/internal/services/securitycenter/client/client.go +++ b/internal/services/securitycenter/client/client.go @@ -5,6 +5,7 @@ package client import ( "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security" // nolint: staticcheck + "github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations" "github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata" "github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage" pricings_v2023_01_01 "github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings" @@ -22,7 +23,7 @@ type Client struct { AdvancedThreatProtectionClient *security.AdvancedThreatProtectionClient AutoProvisioningClient *security.AutoProvisioningSettingsClient SettingClient *security.SettingsClient - AutomationsClient *security.AutomationsClient + AutomationsClient *automations.AutomationsClient ServerVulnerabilityAssessmentClient *security.ServerVulnerabilityAssessmentClient DefenderForStorageClient *defenderforstorage.DefenderForStorageClient } @@ -60,7 +61,7 @@ func NewClient(o *common.ClientOptions) *Client { SettingClient := security.NewSettingsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) o.ConfigureClient(&SettingClient.Client, o.ResourceManagerAuthorizer) - AutomationsClient := security.NewAutomationsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) + AutomationsClient := automations.NewAutomationsClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&AutomationsClient.Client, o.ResourceManagerAuthorizer) ServerVulnerabilityAssessmentClient := security.NewServerVulnerabilityAssessmentClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId, ascLocation) diff --git a/internal/services/securitycenter/security_center_automation_resource.go b/internal/services/securitycenter/security_center_automation_resource.go index e4230415f8dc..0756a64ade91 100644 --- a/internal/services/securitycenter/security_center_automation_resource.go +++ b/internal/services/securitycenter/security_center_automation_resource.go @@ -9,21 +9,23 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/securitycenter/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" "github.com/hashicorp/terraform-provider-azurerm/utils" ) +// TODO: 4.0 - remove these and use the SDK constants instead const ( typeLogicApp = "logicapp" typeEventHub = "eventhub" @@ -98,6 +100,7 @@ func resourceSecurityCenterAutomation() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ + // TODO: 4.0 - remove these and use the SDK constants instead typeLogicApp, typeLogAnalytics, typeEventHub, @@ -137,15 +140,17 @@ func resourceSecurityCenterAutomation() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(security.EventSourceAlerts), - string(security.EventSourceAssessments), - string(security.EventSourceRegulatoryComplianceAssessment), - string(security.EventSourceRegulatoryComplianceAssessmentSnapshot), - string(security.EventSourceSecureScoreControls), - string(security.EventSourceSecureScoreControlsSnapshot), - string(security.EventSourceSecureScores), - string(security.EventSourceSecureScoresSnapshot), - string(security.EventSourceSubAssessments), + string(automations.EventSourceAlerts), + string(automations.EventSourceAssessments), + string(automations.EventSourceAssessmentsSnapshot), + string(automations.EventSourceRegulatoryComplianceAssessment), + string(automations.EventSourceRegulatoryComplianceAssessmentSnapshot), + string(automations.EventSourceSecureScoreControls), + string(automations.EventSourceSecureScoreControlsSnapshot), + string(automations.EventSourceSecureScores), + string(automations.EventSourceSecureScoresSnapshot), + string(automations.EventSourceSubAssessments), + string(automations.EventSourceSubAssessmentsSnapshot), }, false), }, @@ -171,25 +176,25 @@ func resourceSecurityCenterAutomation() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(security.Contains), - string(security.EndsWith), - string(security.Equals), - string(security.GreaterThan), - string(security.GreaterThanOrEqualTo), - string(security.LesserThan), - string(security.LesserThanOrEqualTo), - string(security.NotEquals), - string(security.StartsWith), + string(automations.OperatorContains), + string(automations.OperatorEndsWith), + string(automations.OperatorEquals), + string(automations.OperatorGreaterThan), + string(automations.OperatorGreaterThanOrEqualTo), + string(automations.OperatorLesserThan), + string(automations.OperatorLesserThanOrEqualTo), + string(automations.OperatorNotEquals), + string(automations.OperatorStartsWith), }, false), }, "property_type": { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(security.Integer), - string(security.String), - string(security.Boolean), - string(security.Number), + string(automations.PropertyTypeInteger), + string(automations.PropertyTypeString), + string(automations.PropertyTypeBoolean), + string(automations.PropertyTypeNumber), }, false), }, }, @@ -202,7 +207,7 @@ func resourceSecurityCenterAutomation() *pluginsdk.Resource { }, }, - "tags": tags.Schema(), + "tags": commonschema.TagsForceNew(), }, } } @@ -214,15 +219,16 @@ func resourceSecurityCenterAutomationCreateUpdate(d *pluginsdk.ResourceData, met defer cancel() id := parse.NewAutomationID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + automationId := automations.NewAutomationID(id.SubscriptionId, id.ResourceGroup, id.Name) if d.IsNewResource() { - existing, err := client.Get(ctx, id.ResourceGroup, id.Name) + existing, err := client.Get(ctx, automationId) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_security_center_automation", id.ID()) } } @@ -231,29 +237,29 @@ func resourceSecurityCenterAutomationCreateUpdate(d *pluginsdk.ResourceData, met enabled := d.Get("enabled").(bool) // Build automation struct - automation := security.Automation{ + automation := automations.Automation{ Location: &location, - AutomationProperties: &security.AutomationProperties{ + Properties: &automations.AutomationProperties{ Description: utils.String(d.Get("description").(string)), IsEnabled: &enabled, }, Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } - automation.AutomationProperties.Scopes = expandSecurityCenterAutomationScopes(d.Get("scopes").([]interface{})) + automation.Properties.Scopes = expandSecurityCenterAutomationScopes(d.Get("scopes").([]interface{})) var err error - automation.AutomationProperties.Actions, err = expandSecurityCenterAutomationActions(d.Get("action").([]interface{})) + automation.Properties.Actions, err = expandSecurityCenterAutomationActions(d.Get("action").([]interface{})) if err != nil { return err } - automation.AutomationProperties.Sources, err = expandSecurityCenterAutomationSources(d.Get("source").([]interface{})) + automation.Properties.Sources, err = expandSecurityCenterAutomationSources(d.Get("source").([]interface{})) if err != nil { return err } - if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, automation); err != nil { + if _, err := client.CreateOrUpdate(ctx, automationId, automation); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } @@ -270,10 +276,11 @@ func resourceSecurityCenterAutomationRead(d *pluginsdk.ResourceData, meta interf if err != nil { return err } + automationId := automations.NewAutomationID(id.SubscriptionId, id.ResourceGroup, id.Name) - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, automationId) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { log.Printf("[INFO] %s was not found - removing from state", *id) d.SetId("") return nil @@ -284,9 +291,9 @@ func resourceSecurityCenterAutomationRead(d *pluginsdk.ResourceData, meta interf d.Set("name", id.Name) d.Set("resource_group_name", id.ResourceGroup) - d.Set("location", location.NormalizeNilable(resp.Location)) + d.Set("location", location.NormalizeNilable(resp.Model.Location)) - if properties := resp.AutomationProperties; properties != nil { + if properties := resp.Model.Properties; properties != nil { d.Set("description", properties.Description) d.Set("enabled", properties.IsEnabled) @@ -315,7 +322,7 @@ func resourceSecurityCenterAutomationRead(d *pluginsdk.ResourceData, meta interf } } - return tags.FlattenAndSet(d, resp.Tags) + return tags.FlattenAndSet(d, resp.Model.Tags) } func resourceSecurityCenterAutomationDelete(d *pluginsdk.ResourceData, meta interface{}) error { @@ -327,21 +334,22 @@ func resourceSecurityCenterAutomationDelete(d *pluginsdk.ResourceData, meta inte if err != nil { return err } + automationId := automations.NewAutomationID(id.SubscriptionId, id.ResourceGroup, id.Name) - if _, err := client.Delete(ctx, id.ResourceGroup, id.Name); err != nil { + if _, err := client.Delete(ctx, automationId); err != nil { return fmt.Errorf("deleting %s: %+v", *id, err) } return nil } -func expandSecurityCenterAutomationSources(sourcesRaw []interface{}) (*[]security.AutomationSource, error) { +func expandSecurityCenterAutomationSources(sourcesRaw []interface{}) (*[]automations.AutomationSource, error) { if len(sourcesRaw) == 0 { - return &[]security.AutomationSource{}, nil + return &[]automations.AutomationSource{}, nil } // Output is an array of AutomationSource - output := make([]security.AutomationSource, 0) + output := make([]automations.AutomationSource, 0) // Top level loop over sources array for _, sourceRaw := range sourcesRaw { @@ -351,43 +359,43 @@ func expandSecurityCenterAutomationSources(sourcesRaw []interface{}) (*[]securit } // Build and parse array of RuleSets - ruleSets := make([]security.AutomationRuleSet, 0) + ruleSets := make([]automations.AutomationRuleSet, 0) ruleSetsRaw := sourceMap["rule_set"].([]interface{}) for _, ruleSetRaw := range ruleSetsRaw { ruleSetMap := ruleSetRaw.(map[string]interface{}) rulesRaw := ruleSetMap["rule"].([]interface{}) // Build and parse array of Rules in each RuleSet - rules := make([]security.AutomationTriggeringRule, 0) + rules := make([]automations.AutomationTriggeringRule, 0) for _, ruleRaw := range rulesRaw { // Parse the rule fields ruleMap := ruleRaw.(map[string]interface{}) rulePath := ruleMap["property_path"].(string) - ruleType := security.PropertyType(ruleMap["property_type"].(string)) + ruleType := automations.PropertyType(ruleMap["property_type"].(string)) ruleValue := ruleMap["expected_value"].(string) - ruleOperator := security.Operator(ruleMap["operator"].(string)) + ruleOperator := automations.Operator(ruleMap["operator"].(string)) // Create AutomationTriggeringRule struct and push into array - rule := security.AutomationTriggeringRule{ + rule := automations.AutomationTriggeringRule{ PropertyJPath: &rulePath, - PropertyType: ruleType, + PropertyType: &ruleType, ExpectedValue: &ruleValue, - Operator: ruleOperator, + Operator: &ruleOperator, } rules = append(rules, rule) } // Create AutomationRuleSet struct and push into array - ruleSet := security.AutomationRuleSet{ + ruleSet := automations.AutomationRuleSet{ Rules: &rules, } ruleSets = append(ruleSets, ruleSet) } // Finally create AutomationSource struct holding our list of RuleSets - eventSource := security.EventSource(sourceMap["event_source"].(string)) - source := security.AutomationSource{ - EventSource: eventSource, + eventSource := automations.EventSource(sourceMap["event_source"].(string)) + source := automations.AutomationSource{ + EventSource: &eventSource, RuleSets: &ruleSets, } @@ -398,13 +406,13 @@ func expandSecurityCenterAutomationSources(sourcesRaw []interface{}) (*[]securit return &output, nil } -func expandSecurityCenterAutomationScopes(scopePathsRaw []interface{}) *[]security.AutomationScope { - scopes := make([]security.AutomationScope, 0) +func expandSecurityCenterAutomationScopes(scopePathsRaw []interface{}) *[]automations.AutomationScope { + scopes := make([]automations.AutomationScope, 0) for _, scopePathRaw := range scopePathsRaw { if path, ok := scopePathRaw.(string); ok { desc := fmt.Sprintf("scope for %s", path) - scope := security.AutomationScope{ + scope := automations.AutomationScope{ ScopePath: &path, Description: &desc, } @@ -415,17 +423,17 @@ func expandSecurityCenterAutomationScopes(scopePathsRaw []interface{}) *[]securi return &scopes } -func expandSecurityCenterAutomationActions(actionsRaw []interface{}) (*[]security.BasicAutomationAction, error) { +func expandSecurityCenterAutomationActions(actionsRaw []interface{}) (*[]automations.AutomationAction, error) { if len(actionsRaw) == 0 { - return &[]security.BasicAutomationAction{}, nil + return &[]automations.AutomationAction{}, nil } - output := make([]security.BasicAutomationAction, 0) + output := make([]automations.AutomationAction, 0) for _, actionRaw := range actionsRaw { actionMap := actionRaw.(map[string]interface{}) - var autoAction security.BasicAutomationAction + var autoAction automations.AutomationAction var resourceID string var actionType string var ok bool @@ -442,32 +450,29 @@ func expandSecurityCenterAutomationActions(actionsRaw []interface{}) (*[]securit if triggerURL, ok = actionMap["trigger_url"].(string); !ok || triggerURL == "" { return nil, fmt.Errorf("Security Center automation, trigger_url is required for LogicApp action") } - autoAction = security.AutomationActionLogicApp{ - LogicAppResourceID: &resourceID, - URI: &triggerURL, - ActionType: security.ActionTypeLogicApp, + autoAction = automations.AutomationActionLogicApp{ + LogicAppResourceId: &resourceID, + Uri: &triggerURL, } - // Handle LogAnalytics action type + // Handle LogAnalytics action type case typeLogAnalytics: - autoAction = security.AutomationActionWorkspace{ - WorkspaceResourceID: &resourceID, - ActionType: security.ActionTypeWorkspace, + autoAction = automations.AutomationActionWorkspace{ + WorkspaceResourceId: &resourceID, } - // Handle EventHub action type + // Handle EventHub action type case typeEventHub: var connString string if connString, ok = actionMap["connection_string"].(string); !ok || connString == "" { return nil, fmt.Errorf("Security Center automation, connection_string is required for EventHub action") } - autoAction = security.AutomationActionEventHub{ - EventHubResourceID: &resourceID, + autoAction = automations.AutomationActionEventHub{ + EventHubResourceId: &resourceID, ConnectionString: &connString, - ActionType: security.ActionTypeEventHub, } default: - return nil, fmt.Errorf("Security Center automation, expected action type to be one of: %s, %s or %s", typeEventHub, typeLogAnalytics, typeLogicApp) + return nil, fmt.Errorf("Security Center automation, expected action type to be one of: %s, %s or %s", automations.ActionTypeEventHub, automations.ActionTypeWorkspace, automations.ActionTypeLogicApp) } output = append(output, autoAction) } @@ -475,7 +480,7 @@ func expandSecurityCenterAutomationActions(actionsRaw []interface{}) (*[]securit return &output, nil } -func flattenSecurityCenterAutomationSources(sources *[]security.AutomationSource) ([]map[string]interface{}, error) { +func flattenSecurityCenterAutomationSources(sources *[]automations.AutomationSource) ([]map[string]interface{}, error) { if sources == nil { return make([]map[string]interface{}, 0), nil } @@ -499,8 +504,8 @@ func flattenSecurityCenterAutomationSources(sources *[]security.AutomationSource ruleMap := map[string]string{ "property_path": *rule.PropertyJPath, "expected_value": *rule.ExpectedValue, - "operator": string(rule.Operator), - "property_type": string(rule.PropertyType), + "operator": string(*rule.Operator), + "property_type": string(*rule.PropertyType), } ruleSlice = append(ruleSlice, ruleMap) } @@ -522,7 +527,7 @@ func flattenSecurityCenterAutomationSources(sources *[]security.AutomationSource return resultSlice, nil } -func flattenSecurityCenterAutomationScopes(scopes *[]security.AutomationScope) ([]string, error) { +func flattenSecurityCenterAutomationScopes(scopes *[]automations.AutomationScope) ([]string, error) { if scopes == nil { return []string{}, nil } @@ -539,7 +544,7 @@ func flattenSecurityCenterAutomationScopes(scopes *[]security.AutomationScope) ( return resultSlice, nil } -func flattenSecurityCenterAutomationActions(actions *[]security.BasicAutomationAction, d *pluginsdk.ResourceData) ([]map[string]string, error) { +func flattenSecurityCenterAutomationActions(actions *[]automations.AutomationAction, d *pluginsdk.ResourceData) ([]map[string]string, error) { if actions == nil { return []map[string]string{}, nil } @@ -548,15 +553,15 @@ func flattenSecurityCenterAutomationActions(actions *[]security.BasicAutomationA for i, action := range *actions { // Use type assertion to discover the underlying action - // Trying to use action.(security.AutomationAction).ActionType results in a panic - actionLogicApp, isLogicApp := action.(security.AutomationActionLogicApp) + // Trying to use action.(automations.AutomationAction).ActionType results in a panic + actionLogicApp, isLogicApp := action.(automations.AutomationActionLogicApp) if isLogicApp { - if actionLogicApp.LogicAppResourceID == nil { + if actionLogicApp.LogicAppResourceId == nil { return nil, fmt.Errorf("Security Center automation, API returned an action with empty logicAppResourceId") } actionMap := map[string]string{ - "resource_id": *actionLogicApp.LogicAppResourceID, - "type": "logicapp", + "resource_id": *actionLogicApp.LogicAppResourceId, + "type": string(typeLogicApp), "trigger_url": "", } @@ -569,14 +574,14 @@ func flattenSecurityCenterAutomationActions(actions *[]security.BasicAutomationA resultSlice = append(resultSlice, actionMap) } - actionEventHub, isEventHub := action.(security.AutomationActionEventHub) + actionEventHub, isEventHub := action.(automations.AutomationActionEventHub) if isEventHub { - if actionEventHub.EventHubResourceID == nil { + if actionEventHub.EventHubResourceId == nil { return nil, fmt.Errorf("Security Center automation, API returned an action with empty eventHubResourceId") } actionMap := map[string]string{ - "resource_id": *actionEventHub.EventHubResourceID, - "type": "eventhub", + "resource_id": *actionEventHub.EventHubResourceId, + "type": string(typeEventHub), "connection_string": "", } @@ -589,14 +594,14 @@ func flattenSecurityCenterAutomationActions(actions *[]security.BasicAutomationA resultSlice = append(resultSlice, actionMap) } - actionLogAnalytics, isLogAnalytics := action.(security.AutomationActionWorkspace) + actionLogAnalytics, isLogAnalytics := action.(automations.AutomationActionWorkspace) if isLogAnalytics { - if actionLogAnalytics.WorkspaceResourceID == nil { + if actionLogAnalytics.WorkspaceResourceId == nil { return nil, fmt.Errorf("Security Center automation, API returned an action with empty workspaceResourceId") } actionMap := map[string]string{ - "resource_id": *actionLogAnalytics.WorkspaceResourceID, - "type": "loganalytics", + "resource_id": *actionLogAnalytics.WorkspaceResourceId, + "type": string(typeLogAnalytics), } resultSlice = append(resultSlice, actionMap) diff --git a/internal/services/securitycenter/security_center_automation_resource_test.go b/internal/services/securitycenter/security_center_automation_resource_test.go index 4eebbfe3e286..c48ee7e29e86 100644 --- a/internal/services/securitycenter/security_center_automation_resource_test.go +++ b/internal/services/securitycenter/security_center_automation_resource_test.go @@ -8,6 +8,7 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -217,13 +218,14 @@ func (t SecurityCenterAutomationResource) Exists(ctx context.Context, clients *c if err != nil { return nil, err } + automationId := automations.NewAutomationID(id.SubscriptionId, id.ResourceGroup, id.Name) - resp, err := clients.SecurityCenter.AutomationsClient.Get(ctx, id.ResourceGroup, id.Name) + resp, err := clients.SecurityCenter.AutomationsClient.Get(ctx, automationId) if err != nil { return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.AutomationProperties != nil), nil + return utils.Bool(resp.Model.Properties != nil), nil } func (SecurityCenterAutomationResource) logicApp(data acceptance.TestData) string { diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/README.md new file mode 100644 index 000000000000..66e2727960c9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/README.md @@ -0,0 +1,128 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations` Documentation + +The `automations` SDK allows for interaction with the Azure Resource Manager Service `security` (API Version `2019-01-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations" +``` + + +### Client Initialization + +```go +client := automations.NewAutomationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AutomationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := automations.NewAutomationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "automationValue") + +payload := automations.Automation{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AutomationsClient.Delete` + +```go +ctx := context.TODO() +id := automations.NewAutomationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "automationValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AutomationsClient.Get` + +```go +ctx := context.TODO() +id := automations.NewAutomationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "automationValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AutomationsClient.List` + +```go +ctx := context.TODO() +id := automations.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AutomationsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := automations.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AutomationsClient.Validate` + +```go +ctx := context.TODO() +id := automations.NewAutomationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "automationValue") + +payload := automations.Automation{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/client.go new file mode 100644 index 000000000000..f09d9ae37490 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/client.go @@ -0,0 +1,18 @@ +package automations + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomationsClient struct { + Client autorest.Client + baseUri string +} + +func NewAutomationsClientWithBaseURI(endpoint string) AutomationsClient { + return AutomationsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/constants.go new file mode 100644 index 000000000000..781bcd18c6a8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/constants.go @@ -0,0 +1,175 @@ +package automations + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActionType string + +const ( + ActionTypeEventHub ActionType = "EventHub" + ActionTypeLogicApp ActionType = "LogicApp" + ActionTypeWorkspace ActionType = "Workspace" +) + +func PossibleValuesForActionType() []string { + return []string{ + string(ActionTypeEventHub), + string(ActionTypeLogicApp), + string(ActionTypeWorkspace), + } +} + +func parseActionType(input string) (*ActionType, error) { + vals := map[string]ActionType{ + "eventhub": ActionTypeEventHub, + "logicapp": ActionTypeLogicApp, + "workspace": ActionTypeWorkspace, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActionType(input) + return &out, nil +} + +type EventSource string + +const ( + EventSourceAlerts EventSource = "Alerts" + EventSourceAssessments EventSource = "Assessments" + EventSourceAssessmentsSnapshot EventSource = "AssessmentsSnapshot" + EventSourceRegulatoryComplianceAssessment EventSource = "RegulatoryComplianceAssessment" + EventSourceRegulatoryComplianceAssessmentSnapshot EventSource = "RegulatoryComplianceAssessmentSnapshot" + EventSourceSecureScoreControls EventSource = "SecureScoreControls" + EventSourceSecureScoreControlsSnapshot EventSource = "SecureScoreControlsSnapshot" + EventSourceSecureScores EventSource = "SecureScores" + EventSourceSecureScoresSnapshot EventSource = "SecureScoresSnapshot" + EventSourceSubAssessments EventSource = "SubAssessments" + EventSourceSubAssessmentsSnapshot EventSource = "SubAssessmentsSnapshot" +) + +func PossibleValuesForEventSource() []string { + return []string{ + string(EventSourceAlerts), + string(EventSourceAssessments), + string(EventSourceAssessmentsSnapshot), + string(EventSourceRegulatoryComplianceAssessment), + string(EventSourceRegulatoryComplianceAssessmentSnapshot), + string(EventSourceSecureScoreControls), + string(EventSourceSecureScoreControlsSnapshot), + string(EventSourceSecureScores), + string(EventSourceSecureScoresSnapshot), + string(EventSourceSubAssessments), + string(EventSourceSubAssessmentsSnapshot), + } +} + +func parseEventSource(input string) (*EventSource, error) { + vals := map[string]EventSource{ + "alerts": EventSourceAlerts, + "assessments": EventSourceAssessments, + "assessmentssnapshot": EventSourceAssessmentsSnapshot, + "regulatorycomplianceassessment": EventSourceRegulatoryComplianceAssessment, + "regulatorycomplianceassessmentsnapshot": EventSourceRegulatoryComplianceAssessmentSnapshot, + "securescorecontrols": EventSourceSecureScoreControls, + "securescorecontrolssnapshot": EventSourceSecureScoreControlsSnapshot, + "securescores": EventSourceSecureScores, + "securescoressnapshot": EventSourceSecureScoresSnapshot, + "subassessments": EventSourceSubAssessments, + "subassessmentssnapshot": EventSourceSubAssessmentsSnapshot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EventSource(input) + return &out, nil +} + +type Operator string + +const ( + OperatorContains Operator = "Contains" + OperatorEndsWith Operator = "EndsWith" + OperatorEquals Operator = "Equals" + OperatorGreaterThan Operator = "GreaterThan" + OperatorGreaterThanOrEqualTo Operator = "GreaterThanOrEqualTo" + OperatorLesserThan Operator = "LesserThan" + OperatorLesserThanOrEqualTo Operator = "LesserThanOrEqualTo" + OperatorNotEquals Operator = "NotEquals" + OperatorStartsWith Operator = "StartsWith" +) + +func PossibleValuesForOperator() []string { + return []string{ + string(OperatorContains), + string(OperatorEndsWith), + string(OperatorEquals), + string(OperatorGreaterThan), + string(OperatorGreaterThanOrEqualTo), + string(OperatorLesserThan), + string(OperatorLesserThanOrEqualTo), + string(OperatorNotEquals), + string(OperatorStartsWith), + } +} + +func parseOperator(input string) (*Operator, error) { + vals := map[string]Operator{ + "contains": OperatorContains, + "endswith": OperatorEndsWith, + "equals": OperatorEquals, + "greaterthan": OperatorGreaterThan, + "greaterthanorequalto": OperatorGreaterThanOrEqualTo, + "lesserthan": OperatorLesserThan, + "lesserthanorequalto": OperatorLesserThanOrEqualTo, + "notequals": OperatorNotEquals, + "startswith": OperatorStartsWith, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Operator(input) + return &out, nil +} + +type PropertyType string + +const ( + PropertyTypeBoolean PropertyType = "Boolean" + PropertyTypeInteger PropertyType = "Integer" + PropertyTypeNumber PropertyType = "Number" + PropertyTypeString PropertyType = "String" +) + +func PossibleValuesForPropertyType() []string { + return []string{ + string(PropertyTypeBoolean), + string(PropertyTypeInteger), + string(PropertyTypeNumber), + string(PropertyTypeString), + } +} + +func parsePropertyType(input string) (*PropertyType, error) { + vals := map[string]PropertyType{ + "boolean": PropertyTypeBoolean, + "integer": PropertyTypeInteger, + "number": PropertyTypeNumber, + "string": PropertyTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PropertyType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/id_automation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/id_automation.go new file mode 100644 index 000000000000..d4f677690539 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/id_automation.go @@ -0,0 +1,125 @@ +package automations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = AutomationId{} + +// AutomationId is a struct representing the Resource ID for a Automation +type AutomationId struct { + SubscriptionId string + ResourceGroupName string + AutomationName string +} + +// NewAutomationID returns a new AutomationId struct +func NewAutomationID(subscriptionId string, resourceGroupName string, automationName string) AutomationId { + return AutomationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AutomationName: automationName, + } +} + +// ParseAutomationID parses 'input' into a AutomationId +func ParseAutomationID(input string) (*AutomationId, error) { + parser := resourceids.NewParserFromResourceIdType(AutomationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutomationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAutomationIDInsensitively parses 'input' case-insensitively into a AutomationId +// note: this method should only be used for API response data and not user input +func ParseAutomationIDInsensitively(input string) (*AutomationId, error) { + parser := resourceids.NewParserFromResourceIdType(AutomationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AutomationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AutomationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AutomationName, ok = input.Parsed["automationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "automationName", input) + } + + return nil +} + +// ValidateAutomationID checks that 'input' can be parsed as a Automation ID +func ValidateAutomationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAutomationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Automation ID +func (id AutomationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Security/automations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AutomationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Automation ID +func (id AutomationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftSecurity", "Microsoft.Security", "Microsoft.Security"), + resourceids.StaticSegment("staticAutomations", "automations", "automations"), + resourceids.UserSpecifiedSegment("automationName", "automationValue"), + } +} + +// String returns a human-readable description of this Automation ID +func (id AutomationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Automation Name: %q", id.AutomationName), + } + return fmt.Sprintf("Automation (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_createorupdate_autorest.go new file mode 100644 index 000000000000..94ae3d41efe9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_createorupdate_autorest.go @@ -0,0 +1,69 @@ +package automations + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *Automation +} + +// CreateOrUpdate ... +func (c AutomationsClient) CreateOrUpdate(ctx context.Context, id AutomationId, input Automation) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c AutomationsClient) preparerForCreateOrUpdate(ctx context.Context, id AutomationId, input Automation) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c AutomationsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_delete_autorest.go new file mode 100644 index 000000000000..a6d74dbe9600 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_delete_autorest.go @@ -0,0 +1,66 @@ +package automations + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response +} + +// Delete ... +func (c AutomationsClient) Delete(ctx context.Context, id AutomationId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c AutomationsClient) preparerForDelete(ctx context.Context, id AutomationId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c AutomationsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_get_autorest.go new file mode 100644 index 000000000000..8abeacea42f9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_get_autorest.go @@ -0,0 +1,68 @@ +package automations + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *Automation +} + +// Get ... +func (c AutomationsClient) Get(ctx context.Context, id AutomationId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c AutomationsClient) preparerForGet(ctx context.Context, id AutomationId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c AutomationsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_list_autorest.go new file mode 100644 index 000000000000..ef2fcb618fbf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_list_autorest.go @@ -0,0 +1,187 @@ +package automations + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]Automation + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []Automation +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// List ... +func (c AutomationsClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c AutomationsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/automations", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c AutomationsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c AutomationsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []Automation `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c AutomationsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AutomationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c AutomationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AutomationOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]Automation, 0) + + page, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_listbyresourcegroup_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_listbyresourcegroup_autorest.go new file mode 100644 index 000000000000..87ecc2c21606 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_listbyresourcegroup_autorest.go @@ -0,0 +1,187 @@ +package automations + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + Model *[]Automation + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) +} + +type ListByResourceGroupCompleteResult struct { + Items []Automation +} + +func (r ListByResourceGroupOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByResourceGroup ... +func (c AutomationsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroup(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByResourceGroup(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForListByResourceGroup prepares the ListByResourceGroup request. +func (c AutomationsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Security/automations", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. +func (c AutomationsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (c AutomationsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { + type page struct { + Values []Automation `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByResourceGroup(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListByResourceGroupComplete retrieves all of the results into a single object +func (c AutomationsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AutomationOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c AutomationsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AutomationOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { + items := make([]Automation, 0) + + page, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByResourceGroupCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_validate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_validate_autorest.go new file mode 100644 index 000000000000..4e4a767f065d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/method_validate_autorest.go @@ -0,0 +1,70 @@ +package automations + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationResponse struct { + HttpResponse *http.Response + Model *AutomationValidationStatus +} + +// Validate ... +func (c AutomationsClient) Validate(ctx context.Context, id AutomationId, input Automation) (result ValidateOperationResponse, err error) { + req, err := c.preparerForValidate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Validate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Validate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForValidate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "automations.AutomationsClient", "Validate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForValidate prepares the Validate request. +func (c AutomationsClient) preparerForValidate(ctx context.Context, id AutomationId, input Automation) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/validate", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForValidate handles the response to the Validate request. The method always +// closes the http.Response Body. +func (c AutomationsClient) responderForValidate(resp *http.Response) (result ValidateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automation.go new file mode 100644 index 000000000000..79f592052d37 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automation.go @@ -0,0 +1,15 @@ +package automations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Automation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AutomationProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationaction.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationaction.go new file mode 100644 index 000000000000..27c4b29c654e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationaction.go @@ -0,0 +1,69 @@ +package automations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomationAction interface { +} + +// RawAutomationActionImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawAutomationActionImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalAutomationActionImplementation(input []byte) (AutomationAction, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling AutomationAction into map[string]interface: %+v", err) + } + + value, ok := temp["actionType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "EventHub") { + var out AutomationActionEventHub + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutomationActionEventHub: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "LogicApp") { + var out AutomationActionLogicApp + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutomationActionLogicApp: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Workspace") { + var out AutomationActionWorkspace + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutomationActionWorkspace: %+v", err) + } + return out, nil + } + + out := RawAutomationActionImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactioneventhub.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactioneventhub.go new file mode 100644 index 000000000000..55af2e0a1ee6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactioneventhub.go @@ -0,0 +1,43 @@ +package automations + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutomationAction = AutomationActionEventHub{} + +type AutomationActionEventHub struct { + ConnectionString *string `json:"connectionString,omitempty"` + EventHubResourceId *string `json:"eventHubResourceId,omitempty"` + SasPolicyName *string `json:"sasPolicyName,omitempty"` + + // Fields inherited from AutomationAction +} + +var _ json.Marshaler = AutomationActionEventHub{} + +func (s AutomationActionEventHub) MarshalJSON() ([]byte, error) { + type wrapper AutomationActionEventHub + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutomationActionEventHub: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutomationActionEventHub: %+v", err) + } + decoded["actionType"] = "EventHub" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutomationActionEventHub: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactionlogicapp.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactionlogicapp.go new file mode 100644 index 000000000000..ccbfaaeacfe5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactionlogicapp.go @@ -0,0 +1,42 @@ +package automations + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutomationAction = AutomationActionLogicApp{} + +type AutomationActionLogicApp struct { + LogicAppResourceId *string `json:"logicAppResourceId,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from AutomationAction +} + +var _ json.Marshaler = AutomationActionLogicApp{} + +func (s AutomationActionLogicApp) MarshalJSON() ([]byte, error) { + type wrapper AutomationActionLogicApp + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutomationActionLogicApp: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutomationActionLogicApp: %+v", err) + } + decoded["actionType"] = "LogicApp" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutomationActionLogicApp: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactionworkspace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactionworkspace.go new file mode 100644 index 000000000000..88341552f67c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationactionworkspace.go @@ -0,0 +1,41 @@ +package automations + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutomationAction = AutomationActionWorkspace{} + +type AutomationActionWorkspace struct { + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` + + // Fields inherited from AutomationAction +} + +var _ json.Marshaler = AutomationActionWorkspace{} + +func (s AutomationActionWorkspace) MarshalJSON() ([]byte, error) { + type wrapper AutomationActionWorkspace + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutomationActionWorkspace: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutomationActionWorkspace: %+v", err) + } + decoded["actionType"] = "Workspace" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutomationActionWorkspace: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationproperties.go new file mode 100644 index 000000000000..4003c49465ae --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationproperties.go @@ -0,0 +1,55 @@ +package automations + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomationProperties struct { + Actions *[]AutomationAction `json:"actions,omitempty"` + Description *string `json:"description,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + Scopes *[]AutomationScope `json:"scopes,omitempty"` + Sources *[]AutomationSource `json:"sources,omitempty"` +} + +var _ json.Unmarshaler = &AutomationProperties{} + +func (s *AutomationProperties) UnmarshalJSON(bytes []byte) error { + type alias AutomationProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AutomationProperties: %+v", err) + } + + s.Description = decoded.Description + s.IsEnabled = decoded.IsEnabled + s.Scopes = decoded.Scopes + s.Sources = decoded.Sources + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AutomationProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["actions"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Actions into list []json.RawMessage: %+v", err) + } + + output := make([]AutomationAction, 0) + for i, val := range listTemp { + impl, err := unmarshalAutomationActionImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Actions' for 'AutomationProperties': %+v", i, err) + } + output = append(output, impl) + } + s.Actions = &output + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationruleset.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationruleset.go new file mode 100644 index 000000000000..089a404b270b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationruleset.go @@ -0,0 +1,8 @@ +package automations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomationRuleSet struct { + Rules *[]AutomationTriggeringRule `json:"rules,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationscope.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationscope.go new file mode 100644 index 000000000000..5959c5cce77d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationscope.go @@ -0,0 +1,9 @@ +package automations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomationScope struct { + Description *string `json:"description,omitempty"` + ScopePath *string `json:"scopePath,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationsource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationsource.go new file mode 100644 index 000000000000..a8d99b06791d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationsource.go @@ -0,0 +1,9 @@ +package automations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomationSource struct { + EventSource *EventSource `json:"eventSource,omitempty"` + RuleSets *[]AutomationRuleSet `json:"ruleSets,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationtriggeringrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationtriggeringrule.go new file mode 100644 index 000000000000..11ab3143700d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationtriggeringrule.go @@ -0,0 +1,11 @@ +package automations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomationTriggeringRule struct { + ExpectedValue *string `json:"expectedValue,omitempty"` + Operator *Operator `json:"operator,omitempty"` + PropertyJPath *string `json:"propertyJPath,omitempty"` + PropertyType *PropertyType `json:"propertyType,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationvalidationstatus.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationvalidationstatus.go new file mode 100644 index 000000000000..679a394a964f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/model_automationvalidationstatus.go @@ -0,0 +1,9 @@ +package automations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomationValidationStatus struct { + IsValid *bool `json:"isValid,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/predicates.go new file mode 100644 index 000000000000..a6cfd2c64e78 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/predicates.go @@ -0,0 +1,42 @@ +package automations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomationOperationPredicate struct { + Etag *string + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AutomationOperationPredicate) Matches(input Automation) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/version.go new file mode 100644 index 000000000000..9cf92e72877f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations/version.go @@ -0,0 +1,12 @@ +package automations + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2019-01-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/automations/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index ed14c8d88d06..9ea3165cf6cb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -880,6 +880,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/search/2023-11-01/adminkeys github.com/hashicorp/go-azure-sdk/resource-manager/search/2023-11-01/querykeys github.com/hashicorp/go-azure-sdk/resource-manager/search/2023-11-01/services github.com/hashicorp/go-azure-sdk/resource-manager/search/2023-11-01/sharedprivatelinkresources +github.com/hashicorp/go-azure-sdk/resource-manager/security/2019-01-01-preview/automations github.com/hashicorp/go-azure-sdk/resource-manager/security/2021-06-01/assessmentsmetadata github.com/hashicorp/go-azure-sdk/resource-manager/security/2022-12-01-preview/defenderforstorage github.com/hashicorp/go-azure-sdk/resource-manager/security/2023-01-01/pricings