diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index 49f9c4991eab..988a2529cfb6 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -35,6 +35,9 @@ service/authorization: - internal/services/authorization/**/* - internal/services/managedidentity/**/* +service/automanage: + - internal/services/automanage/**/* + service/automation: - internal/services/automation/**/* diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 2ad895275f2b..a7f261714a37 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -11,6 +11,7 @@ var services = mapOf( "arckubernetes" to "ArcKubernetes", "attestation" to "Attestation", "authorization" to "Authorization", + "automanage" to "Automanage", "automation" to "Automation", "azurestackhci" to "Azure Stack HCI", "batch" to "Batch", diff --git a/internal/clients/client.go b/internal/clients/client.go index ab538bf8e053..6ab09cc1ef62 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -27,6 +27,7 @@ import ( arckubernetes "github.com/hashicorp/terraform-provider-azurerm/internal/services/arckubernetes/client" attestation "github.com/hashicorp/terraform-provider-azurerm/internal/services/attestation/client" authorization "github.com/hashicorp/terraform-provider-azurerm/internal/services/authorization/client" + automanage "github.com/hashicorp/terraform-provider-azurerm/internal/services/automanage/client" automation "github.com/hashicorp/terraform-provider-azurerm/internal/services/automation/client" azureStackHCI "github.com/hashicorp/terraform-provider-azurerm/internal/services/azurestackhci/client" batch "github.com/hashicorp/terraform-provider-azurerm/internal/services/batch/client" @@ -153,6 +154,7 @@ type Client struct { ArcKubernetes *arckubernetes.Client Attestation *attestation.Client Authorization *authorization.Client + Automanage *automanage.Client Automation *automation.Client AzureStackHCI *azurestackhci_v2022_12_01.Client Batch *batch.Client @@ -295,6 +297,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error return fmt.Errorf("building clients for Attestation: %+v", err) } client.Authorization = authorization.NewClient(o) + client.Automanage = automanage.NewClient(o) client.Automation = automation.NewClient(o) client.AzureStackHCI = azureStackHCI.NewClient(o) if client.Batch, err = batch.NewClient(o); err != nil { diff --git a/internal/provider/services.go b/internal/provider/services.go index 371d68e2be54..678ecf162860 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/arckubernetes" "github.com/hashicorp/terraform-provider-azurerm/internal/services/attestation" "github.com/hashicorp/terraform-provider-azurerm/internal/services/authorization" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/automanage" "github.com/hashicorp/terraform-provider-azurerm/internal/services/automation" "github.com/hashicorp/terraform-provider-azurerm/internal/services/azurestackhci" "github.com/hashicorp/terraform-provider-azurerm/internal/services/batch" @@ -130,6 +131,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { applicationinsights.Registration{}, appservice.Registration{}, arckubernetes.Registration{}, + automanage.Registration{}, automation.Registration{}, batch.Registration{}, bot.Registration{}, diff --git a/internal/services/automanage/automanage_configuration_resource.go b/internal/services/automanage/automanage_configuration_resource.go new file mode 100644 index 000000000000..becc10581f44 --- /dev/null +++ b/internal/services/automanage/automanage_configuration_resource.go @@ -0,0 +1,473 @@ +package automanage + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/automanage/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/automanage/validate" + "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/utils" + "github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage" +) + +type ConfigurationModel struct { + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + + Antimalware []AntimalwareConfiguration `tfschema:"antimalware"` + AutomationAccountEnabled bool `tfschema:"automation_account_enabled"` + BootDiagnosticsEnabled bool `tfschema:"boot_diagnostics_enabled"` + DefenderForCloudEnabled bool `tfschema:"defender_for_cloud_enabled"` + GuestConfigurationEnabled bool `tfschema:"guest_configuration_enabled"` + StatusChangeAlertEnabled bool `tfschema:"status_change_alert_enabled"` + + Location string `tfschema:"location"` + Tags map[string]string `tfschema:"tags"` +} + +type AntimalwareConfiguration struct { + Exclusions []AntimalwareExclusions `tfschema:"exclusions"` + RealTimeProtectionEnabled bool `tfschema:"real_time_protection_enabled"` + ScheduledScanEnabled bool `tfschema:"scheduled_scan_enabled"` + ScanType string `tfschema:"scheduled_scan_type"` + ScanDay int `tfschema:"scheduled_scan_day"` + ScanTimeInMinutes int `tfschema:"scheduled_scan_time_in_minutes"` +} + +type AntimalwareExclusions struct { + Extensions string `tfschema:"extensions"` + Paths string `tfschema:"paths"` + Processes string `tfschema:"processes"` +} + +type AutoManageConfigurationResource struct{} + +var _ sdk.ResourceWithUpdate = AutoManageConfigurationResource{} + +func (r AutoManageConfigurationResource) ResourceType() string { + return "azurerm_automanage_configuration" +} + +func (r AutoManageConfigurationResource) ModelObject() interface{} { + return &ConfigurationModel{} +} + +func (r AutoManageConfigurationResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return validate.AutomanageConfigurationID +} + +func (r AutoManageConfigurationResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "resource_group_name": commonschema.ResourceGroupName(), + + "location": commonschema.Location(), + + // "Antimalware/Enable": boolean, true if block exists + // "Antimalware/EnableRealTimeProtection": boolean, + // "Antimalware/RunScheduledScan": boolean, + // "Antimalware/ScanType": string ("Quick", "Full"), + // "Antimalware/ScanDay": int (0-8) Ex: 0 - daily, 1 - Sunday, 2 - Monday, .... 7 - Saturday, 8 - Disabled, + // "Antimalware/ScanTimeInMinutes": int (0 - 1440), + // "Antimalware/Exclusions/Extensions": string (extensions separated by semicolon. Ex: ".ext1;.ext2"), + // "Antimalware/Exclusions/Paths": string (Paths separated by semicolon. Ex: "c:\excluded-path-1;c:\excluded-path-2"), + // "Antimalware/Exclusions/Processes": string (Processes separated by semicolon. Ex: "proc1.exe;proc2.exe"), + "antimalware": { + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "real_time_protection_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + "scheduled_scan_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + "scheduled_scan_type": { + Type: pluginsdk.TypeString, + Optional: true, + Default: "Quick", + ValidateFunc: validation.StringInSlice([]string{ + "Quick", + "Full", + }, false), + }, + "scheduled_scan_day": { + Type: pluginsdk.TypeInt, + Optional: true, + Default: 8, + ValidateFunc: validation.IntInSlice([]int{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, + }), + }, + "scheduled_scan_time_in_minutes": { + Type: pluginsdk.TypeInt, + Optional: true, + Default: 0, + ValidateFunc: validation.IntBetween(0, 1439), + }, + "exclusions": { + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "extensions": { + Type: pluginsdk.TypeString, + Optional: true, + }, + "paths": { + Type: pluginsdk.TypeString, + Optional: true, + }, + "processes": { + Type: pluginsdk.TypeString, + Optional: true, + }, + }, + }, + }, + }, + }, + }, + + // "AutomationAccount/Enable": boolean, + "automation_account_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + // "BootDiagnostics/Enable": boolean, + "boot_diagnostics_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + // "DefenderForCloud/Enable": boolean, + "defender_for_cloud_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + // "GuestConfiguration/Enable": boolean, + "guest_configuration_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + // "Alerts/AutomanageStatusChanges/Enable": boolean, + "status_change_alert_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "tags": commonschema.Tags(), + } +} + +func (r AutoManageConfigurationResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r AutoManageConfigurationResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model ConfigurationModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.Automanage.ConfigurationClient + subscriptionId := metadata.Client.Account.SubscriptionId + id := parse.NewAutomanageConfigurationID(subscriptionId, model.ResourceGroupName, model.Name) + existing, err := client.Get(ctx, id.ConfigurationProfileName, id.ResourceGroup) + if err != nil && !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("checking for existing %s: %+v", id, err) + } + + if !utils.ResponseWasNotFound(existing.Response) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + properties := automanage.ConfigurationProfile{ + Location: utils.String(location.Normalize(model.Location)), + Properties: &automanage.ConfigurationProfileProperties{}, + Tags: tags.FromTypedObject(model.Tags), + } + + // building configuration profile in json format + jsonConfig := make(map[string]interface{}) + + if model.Antimalware != nil && len(model.Antimalware) > 0 { + antimalwareConfig := model.Antimalware[0] + jsonConfig["Antimalware/Enable"] = true + jsonConfig["Antimalware/EnableRealTimeProtection"] = antimalwareConfig.RealTimeProtectionEnabled + jsonConfig["Antimalware/RunScheduledScan"] = antimalwareConfig.ScheduledScanEnabled + jsonConfig["Antimalware/ScanType"] = antimalwareConfig.ScanType + jsonConfig["Antimalware/ScanDay"] = antimalwareConfig.ScanDay + jsonConfig["Antimalware/ScanTimeInMinutes"] = antimalwareConfig.ScanTimeInMinutes + if antimalwareConfig.Exclusions != nil && len(antimalwareConfig.Exclusions) > 0 { + jsonConfig["Antimalware/Exclusions/Extensions"] = antimalwareConfig.Exclusions[0].Extensions + jsonConfig["Antimalware/Exclusions/Paths"] = antimalwareConfig.Exclusions[0].Paths + jsonConfig["Antimalware/Exclusions/Processes"] = antimalwareConfig.Exclusions[0].Processes + } + } + + if model.AutomationAccountEnabled { + jsonConfig["AutomationAccount/Enable"] = model.AutomationAccountEnabled + } + + if model.BootDiagnosticsEnabled { + jsonConfig["BootDiagnostics/Enable"] = model.BootDiagnosticsEnabled + } + + if model.DefenderForCloudEnabled { + jsonConfig["DefenderForCloud/Enable"] = model.DefenderForCloudEnabled + } + + if model.GuestConfigurationEnabled { + jsonConfig["GuestConfiguration/Enable"] = model.GuestConfigurationEnabled + } + + if model.StatusChangeAlertEnabled { + jsonConfig["Alerts/AutomanageStatusChanges/Enable"] = model.StatusChangeAlertEnabled + } + + properties.Properties.Configuration = &jsonConfig + + if _, err := client.CreateOrUpdate(ctx, id.ConfigurationProfileName, id.ResourceGroup, properties); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r AutoManageConfigurationResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Automanage.ConfigurationClient + + id, err := parse.AutomanageConfigurationID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model ConfigurationModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + resp, err := client.Get(ctx, id.ConfigurationProfileName, id.ResourceGroup) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + jsonConfig := make(map[string]interface{}) + + if model.Antimalware != nil && len(model.Antimalware) > 0 { + antimalwareConfig := model.Antimalware[0] + jsonConfig["Antimalware/Enable"] = true + jsonConfig["Antimalware/EnableRealTimeProtection"] = antimalwareConfig.RealTimeProtectionEnabled + jsonConfig["Antimalware/RunScheduledScan"] = antimalwareConfig.ScheduledScanEnabled + jsonConfig["Antimalware/ScanType"] = antimalwareConfig.ScanType + jsonConfig["Antimalware/ScanDay"] = antimalwareConfig.ScanDay + jsonConfig["Antimalware/ScanTimeInMinutes"] = antimalwareConfig.ScanTimeInMinutes + if antimalwareConfig.Exclusions != nil && len(antimalwareConfig.Exclusions) > 0 { + jsonConfig["Antimalware/Exclusions/Extensions"] = antimalwareConfig.Exclusions[0].Extensions + jsonConfig["Antimalware/Exclusions/Paths"] = antimalwareConfig.Exclusions[0].Paths + jsonConfig["Antimalware/Exclusions/Processes"] = antimalwareConfig.Exclusions[0].Processes + } + } + + if metadata.ResourceData.HasChange("automation_account_enabled") { + jsonConfig["AutomationAccount/Enable"] = model.AutomationAccountEnabled + } + + if metadata.ResourceData.HasChange("boot_diagnostics_enabled") { + jsonConfig["BootDiagnostics/Enable"] = model.BootDiagnosticsEnabled + } + + if metadata.ResourceData.HasChange("defender_for_cloud_enabled") { + jsonConfig["DefenderForCloud/Enable"] = model.DefenderForCloudEnabled + } + + if metadata.ResourceData.HasChange("guest_configuration_enabled") { + jsonConfig["GuestConfiguration/Enable"] = model.GuestConfigurationEnabled + } + + if metadata.ResourceData.HasChange("status_change_alert_enabled") { + jsonConfig["Alerts/AutomanageStatusChanges/Enable"] = model.StatusChangeAlertEnabled + } + + if metadata.ResourceData.HasChange("tags") { + resp.Tags = tags.FromTypedObject(model.Tags) + } + + properties := automanage.ConfigurationProfile{ + Location: utils.String(metadata.ResourceData.Get("location").(string)), + Properties: &automanage.ConfigurationProfileProperties{ + Configuration: &jsonConfig, + }, + Tags: resp.Tags, + } + + if _, err := client.CreateOrUpdate(ctx, id.ConfigurationProfileName, id.ResourceGroup, properties); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r AutoManageConfigurationResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Automanage.ConfigurationClient + + id, err := parse.AutomanageConfigurationID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, id.ConfigurationProfileName, id.ResourceGroup) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return metadata.MarkAsGone(id) + } + + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + state := ConfigurationModel{ + Name: id.ConfigurationProfileName, + ResourceGroupName: id.ResourceGroup, + Location: location.NormalizeNilable(resp.Location), + } + + if resp.Properties != nil && resp.Properties.Configuration != nil { + configMap := resp.Properties.Configuration.(map[string]interface{}) + + state.Antimalware = flattenAntimarewareConfig(configMap) + + if val, ok := configMap["AutomationAccount/Enable"]; ok { + state.AutomationAccountEnabled = val.(bool) + } + + if val, ok := configMap["BootDiagnostics/Enable"]; ok { + state.BootDiagnosticsEnabled = val.(bool) + } + + if val, ok := configMap["DefenderForCloud/Enable"]; ok { + state.DefenderForCloudEnabled = val.(bool) + } + + if val, ok := configMap["GuestConfiguration/Enable"]; ok { + state.GuestConfigurationEnabled = val.(bool) + } + + if val, ok := configMap["Alerts/AutomanageStatusChanges/Enable"]; ok { + state.StatusChangeAlertEnabled = val.(bool) + } + } + + if resp.Tags != nil { + state.Tags = tags.ToTypedObject(resp.Tags) + } + + return metadata.Encode(&state) + }, + } +} + +func (r AutoManageConfigurationResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Automanage.ConfigurationClient + + id, err := parse.AutomanageConfigurationID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if _, err := client.Delete(ctx, id.ResourceGroup, id.ConfigurationProfileName); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) + } + + return nil + }, + } +} + +func flattenAntimarewareConfig(configMap map[string]interface{}) []AntimalwareConfiguration { + if val, ok := configMap["Antimalware/Enable"]; !ok || (val == nil) { + return nil + } + + antimalware := make([]AntimalwareConfiguration, 1) + antimalware[0] = AntimalwareConfiguration{} + antimalware[0].Exclusions = make([]AntimalwareExclusions, 1) + + if val, ok := configMap["Antimalware/EnableRealTimeProtection"]; ok { + antimalware[0].RealTimeProtectionEnabled = val.(bool) + } + + if val, ok := configMap["Antimalware/RunScheduledScan"]; ok { + antimalware[0].ScheduledScanEnabled = val.(bool) + } + + if val, ok := configMap["Antimalware/ScanType"]; ok { + antimalware[0].ScanType = val.(string) + } + + if val, ok := configMap["Antimalware/ScanDay"]; ok { + antimalware[0].ScanDay = int(val.(float64)) + } + + if val, ok := configMap["Antimalware/ScanTimeInMinutes"]; ok { + antimalware[0].ScanTimeInMinutes = int(val.(float64)) + } + + if val, ok := configMap["Antimalware/Exclusions/Extensions"]; ok { + antimalware[0].Exclusions[0].Extensions = val.(string) + } + + if val, ok := configMap["Antimalware/Exclusions/Paths"]; ok { + antimalware[0].Exclusions[0].Paths = val.(string) + } + + if val, ok := configMap["Antimalware/Exclusions/Processes"]; ok { + antimalware[0].Exclusions[0].Processes = val.(string) + } + + return antimalware +} diff --git a/internal/services/automanage/automanage_configuration_resource_test.go b/internal/services/automanage/automanage_configuration_resource_test.go new file mode 100644 index 000000000000..c61ed5f47312 --- /dev/null +++ b/internal/services/automanage/automanage_configuration_resource_test.go @@ -0,0 +1,272 @@ +package automanage_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/automanage/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type AutoManageConfigurationProfileResource struct{} + +func TestAccAutoManageConfigurationProfile_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_automanage_configuration", "test") + r := AutoManageConfigurationProfileResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccAutoManageConfigurationProfile_antimalware(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_automanage_configuration", "test") + r := AutoManageConfigurationProfileResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.antimalware(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("antimalware.#").HasValue("1"), + check.That(data.ResourceName).Key("antimalware.0.exclusions.#").HasValue("1"), + check.That(data.ResourceName).Key("antimalware.0.exclusions.0.extensions").HasValue("exe;dll"), + check.That(data.ResourceName).Key("antimalware.0.real_time_protection_enabled").HasValue("true"), + check.That(data.ResourceName).Key("automation_account_enabled").HasValue("true"), + ), + }, + data.ImportStep(), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("antimalware.#").HasValue("0"), + check.That(data.ResourceName).Key("automation_account_enabled").HasValue("false"), + ), + }, + data.ImportStep(), + }) +} + +func TestAccAutoManageConfigurationProfile_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_automanage_configuration", "test") + r := AutoManageConfigurationProfileResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccAutoManageConfigurationProfile_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_automanage_configuration", "test") + r := AutoManageConfigurationProfileResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("antimalware.#").HasValue("1"), + check.That(data.ResourceName).Key("antimalware.0.exclusions.#").HasValue("1"), + check.That(data.ResourceName).Key("antimalware.0.exclusions.0.extensions").HasValue("exe;dll"), + check.That(data.ResourceName).Key("antimalware.0.exclusions.0.processes").HasValue("svchost.exe;notepad.exe"), + check.That(data.ResourceName).Key("antimalware.0.real_time_protection_enabled").HasValue("true"), + check.That(data.ResourceName).Key("antimalware.0.scheduled_scan_enabled").HasValue("true"), + check.That(data.ResourceName).Key("antimalware.0.scheduled_scan_day").HasValue("1"), + check.That(data.ResourceName).Key("antimalware.0.scheduled_scan_type").HasValue("Quick"), + check.That(data.ResourceName).Key("antimalware.0.scheduled_scan_time_in_minutes").HasValue("1339"), + check.That(data.ResourceName).Key("automation_account_enabled").HasValue("true"), + check.That(data.ResourceName).Key("boot_diagnostics_enabled").HasValue("true"), + check.That(data.ResourceName).Key("defender_for_cloud_enabled").HasValue("true"), + check.That(data.ResourceName).Key("guest_configuration_enabled").HasValue("true"), + check.That(data.ResourceName).Key("status_change_alert_enabled").HasValue("true"), + ), + }, + data.ImportStep(), + }) +} + +func TestAccAutoManageConfigurationProfile_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_automanage_configuration", "test") + r := AutoManageConfigurationProfileResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("antimalware.#").HasValue("1"), + check.That(data.ResourceName).Key("antimalware.0.exclusions.#").HasValue("1"), + check.That(data.ResourceName).Key("antimalware.0.exclusions.0.extensions").HasValue("exe"), + check.That(data.ResourceName).Key("antimalware.0.exclusions.0.processes").HasValue("svchost.exe"), + check.That(data.ResourceName).Key("antimalware.0.real_time_protection_enabled").HasValue("false"), + check.That(data.ResourceName).Key("antimalware.0.scheduled_scan_enabled").HasValue("true"), + check.That(data.ResourceName).Key("antimalware.0.scheduled_scan_day").HasValue("2"), + check.That(data.ResourceName).Key("antimalware.0.scheduled_scan_type").HasValue("Full"), + check.That(data.ResourceName).Key("antimalware.0.scheduled_scan_time_in_minutes").HasValue("1338"), + check.That(data.ResourceName).Key("automation_account_enabled").HasValue("false"), + check.That(data.ResourceName).Key("boot_diagnostics_enabled").HasValue("false"), + check.That(data.ResourceName).Key("defender_for_cloud_enabled").HasValue("false"), + check.That(data.ResourceName).Key("guest_configuration_enabled").HasValue("false"), + check.That(data.ResourceName).Key("status_change_alert_enabled").HasValue("false"), + ), + }, + data.ImportStep(), + }) +} + +func (r AutoManageConfigurationProfileResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := parse.AutomanageConfigurationID(state.ID) + if err != nil { + return nil, err + } + + client := clients.Automanage.ConfigurationClient + resp, err := client.Get(ctx, id.ConfigurationProfileName, id.ResourceGroup) + if err != nil { + if response.WasNotFound(resp.Response.Response) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retrieving %s: %+v", id, err) + } + return utils.Bool(resp.Response.Response != nil), nil +} + +func (r AutoManageConfigurationProfileResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctest-rg-%d" + location = "%s" +} +`, data.RandomInteger, data.Locations.Primary) +} + +func (r AutoManageConfigurationProfileResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_automanage_configuration" "test" { + name = "acctest-amcp-%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" +} +`, template, data.RandomInteger, data.Locations.Primary) +} + +func (r AutoManageConfigurationProfileResource) antimalware(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_automanage_configuration" "test" { + name = "acctest-amcp-%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" + antimalware { + exclusions { + extensions = "exe;dll" + } + real_time_protection_enabled = true + } + automation_account_enabled = true +} +`, template, data.RandomInteger, data.Locations.Primary) +} + +func (r AutoManageConfigurationProfileResource) requiresImport(data acceptance.TestData) string { + config := r.antimalware(data) + return fmt.Sprintf(` + %s + +resource "azurerm_automanage_configuration" "import" { + name = azurerm_automanage_configuration.test.name + resource_group_name = azurerm_resource_group.test.name + location = "%s" +} +`, config, data.Locations.Primary) +} + +func (r AutoManageConfigurationProfileResource) complete(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_automanage_configuration" "test" { + name = "acctest-amcp-%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" + antimalware { + exclusions { + extensions = "exe;dll" + paths = "C:\\Windows\\Temp;D:\\Temp" + processes = "svchost.exe;notepad.exe" + } + real_time_protection_enabled = true + scheduled_scan_enabled = true + scheduled_scan_type = "Quick" + scheduled_scan_day = 1 + scheduled_scan_time_in_minutes = 1339 + } + automation_account_enabled = true + boot_diagnostics_enabled = true + defender_for_cloud_enabled = true + guest_configuration_enabled = true + status_change_alert_enabled = true + tags = { + "env" = "test" + } +} +`, template, data.RandomInteger, data.Locations.Primary) +} + +func (r AutoManageConfigurationProfileResource) update(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_automanage_configuration" "test" { + name = "acctest-amcp-%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" + antimalware { + exclusions { + extensions = "exe" + processes = "svchost.exe" + } + real_time_protection_enabled = false + scheduled_scan_enabled = true + scheduled_scan_type = "Full" + scheduled_scan_day = 2 + scheduled_scan_time_in_minutes = 1338 + } + tags = { + "env2" = "test2" + } +} +`, template, data.RandomInteger, data.Locations.Primary) +} diff --git a/internal/services/automanage/client/client.go b/internal/services/automanage/client/client.go new file mode 100644 index 000000000000..977ee8e428d4 --- /dev/null +++ b/internal/services/automanage/client/client.go @@ -0,0 +1,19 @@ +package client + +import ( + "github.com/hashicorp/terraform-provider-azurerm/internal/common" + "github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage" +) + +type Client struct { + ConfigurationClient *automanage.ConfigurationProfilesClient +} + +func NewClient(o *common.ClientOptions) *Client { + configurationProfileClient := automanage.NewConfigurationProfilesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&configurationProfileClient.Client, o.ResourceManagerAuthorizer) + + return &Client{ + ConfigurationClient: &configurationProfileClient, + } +} diff --git a/internal/services/automanage/parse/automanage_configuration.go b/internal/services/automanage/parse/automanage_configuration.go new file mode 100644 index 000000000000..cc3d629d2182 --- /dev/null +++ b/internal/services/automanage/parse/automanage_configuration.go @@ -0,0 +1,69 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +type AutomanageConfigurationId struct { + SubscriptionId string + ResourceGroup string + ConfigurationProfileName string +} + +func NewAutomanageConfigurationID(subscriptionId, resourceGroup, configurationProfileName string) AutomanageConfigurationId { + return AutomanageConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + ConfigurationProfileName: configurationProfileName, + } +} + +func (id AutomanageConfigurationId) String() string { + segments := []string{ + fmt.Sprintf("Configuration Profile Name %q", id.ConfigurationProfileName), + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + } + segmentsStr := strings.Join(segments, " / ") + return fmt.Sprintf("%s: (%s)", "Automanage Configuration", segmentsStr) +} + +func (id AutomanageConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Automanage/configurationProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.ConfigurationProfileName) +} + +// AutomanageConfigurationID parses a AutomanageConfiguration ID into an AutomanageConfigurationId struct +func AutomanageConfigurationID(input string) (*AutomanageConfigurationId, error) { + id, err := resourceids.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as an AutomanageConfiguration ID: %+v", input, err) + } + + resourceId := AutomanageConfigurationId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, + } + + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") + } + + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") + } + + if resourceId.ConfigurationProfileName, err = id.PopSegment("configurationProfiles"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &resourceId, nil +} diff --git a/internal/services/automanage/parse/automanage_configuration_test.go b/internal/services/automanage/parse/automanage_configuration_test.go new file mode 100644 index 000000000000..81fef858b5c6 --- /dev/null +++ b/internal/services/automanage/parse/automanage_configuration_test.go @@ -0,0 +1,112 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.Id = AutomanageConfigurationId{} + +func TestAutomanageConfigurationIDFormatter(t *testing.T) { + actual := NewAutomanageConfigurationID("12345678-1234-9876-4563-123456789012", "resourceGroup1", "configurationProfile1").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.Automanage/configurationProfiles/configurationProfile1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestAutomanageConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AutomanageConfigurationId + }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Error: true, + }, + + { + // missing ConfigurationProfileName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.Automanage/", + Error: true, + }, + + { + // missing value for ConfigurationProfileName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.Automanage/configurationProfiles/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.Automanage/configurationProfiles/configurationProfile1", + Expected: &AutomanageConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resourceGroup1", + ConfigurationProfileName: "configurationProfile1", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.AUTOMANAGE/CONFIGURATIONPROFILES/CONFIGURATIONPROFILE1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := AutomanageConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + if actual.ConfigurationProfileName != v.Expected.ConfigurationProfileName { + t.Fatalf("Expected %q but got %q for ConfigurationProfileName", v.Expected.ConfigurationProfileName, actual.ConfigurationProfileName) + } + } +} diff --git a/internal/services/automanage/registration.go b/internal/services/automanage/registration.go new file mode 100644 index 000000000000..4cf2841c0351 --- /dev/null +++ b/internal/services/automanage/registration.go @@ -0,0 +1,51 @@ +package automanage + +import ( + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type Registration struct{} + +var ( + _ sdk.TypedServiceRegistrationWithAGitHubLabel = Registration{} + _ sdk.UntypedServiceRegistrationWithAGitHubLabel = Registration{} +) + +func (r Registration) AssociatedGitHubLabel() string { + return "service/automanage" +} + +// Name is the name of this Service +func (r Registration) Name() string { + return "Automanage" +} + +// WebsiteCategories returns a list of categories which can be used for the sidebar +func (r Registration) WebsiteCategories() []string { + return []string{ + "Automanage", + } +} + +// SupportedDataSources returns the supported Data Sources supported by this Service +func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource { + return map[string]*pluginsdk.Resource{} +} + +// SupportedResources returns the supported Resources supported by this Service +func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { + return map[string]*pluginsdk.Resource{} +} + +// DataSources returns a list of Data Sources supported by this Service +func (r Registration) DataSources() []sdk.DataSource { + return []sdk.DataSource{} +} + +// Resources returns a list of Resources supported by this Service +func (r Registration) Resources() []sdk.Resource { + return []sdk.Resource{ + AutoManageConfigurationResource{}, + } +} diff --git a/internal/services/automanage/resourceid.go b/internal/services/automanage/resourceid.go new file mode 100644 index 000000000000..912bb4e3655a --- /dev/null +++ b/internal/services/automanage/resourceid.go @@ -0,0 +1,4 @@ +package automanage + +// leaving the Automanage prefix here to avoid stuttering the property name for now +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=AutomanageConfiguration -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.Automanage/configurationProfiles/configurationProfile1 diff --git a/internal/services/automanage/validate/automanage_configuration_id.go b/internal/services/automanage/validate/automanage_configuration_id.go new file mode 100644 index 000000000000..ef5c822a2085 --- /dev/null +++ b/internal/services/automanage/validate/automanage_configuration_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/hashicorp/terraform-provider-azurerm/internal/services/automanage/parse" +) + +func AutomanageConfigurationID(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 := parse.AutomanageConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/internal/services/automanage/validate/automanage_configuration_id_test.go b/internal/services/automanage/validate/automanage_configuration_id_test.go new file mode 100644 index 000000000000..6572ae152c8f --- /dev/null +++ b/internal/services/automanage/validate/automanage_configuration_id_test.go @@ -0,0 +1,76 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestAutomanageConfigurationID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing ConfigurationProfileName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.Automanage/", + Valid: false, + }, + + { + // missing value for ConfigurationProfileName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.Automanage/configurationProfiles/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.Automanage/configurationProfiles/configurationProfile1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.AUTOMANAGE/CONFIGURATIONPROFILES/CONFIGURATIONPROFILE1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := AutomanageConfigurationID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/bestpractices.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/bestpractices.go new file mode 100644 index 000000000000..30091eb1fff6 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/bestpractices.go @@ -0,0 +1,172 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" +) + +// BestPracticesClient is the automanage Client +type BestPracticesClient struct { + BaseClient +} + +// NewBestPracticesClient creates an instance of the BestPracticesClient client. +func NewBestPracticesClient(subscriptionID string) BestPracticesClient { + return NewBestPracticesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBestPracticesClientWithBaseURI creates an instance of the BestPracticesClient 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 NewBestPracticesClientWithBaseURI(baseURI string, subscriptionID string) BestPracticesClient { + return BestPracticesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get information about a Automanage best practice +// Parameters: +// bestPracticeName - the Automanage best practice name. +func (client BestPracticesClient) Get(ctx context.Context, bestPracticeName string) (result BestPractice, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BestPracticesClient.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, bestPracticeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.BestPracticesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.BestPracticesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.BestPracticesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client BestPracticesClient) GetPreparer(ctx context.Context, bestPracticeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "bestPracticeName": autorest.Encode("path", bestPracticeName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}", 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 BestPracticesClient) 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 BestPracticesClient) GetResponder(resp *http.Response) (result BestPractice, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByTenant retrieve a list of Automanage best practices +func (client BestPracticesClient) ListByTenant(ctx context.Context) (result BestPracticeList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BestPracticesClient.ListByTenant") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByTenantPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.BestPracticesClient", "ListByTenant", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTenantSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.BestPracticesClient", "ListByTenant", resp, "Failure sending request") + return + } + + result, err = client.ListByTenantResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.BestPracticesClient", "ListByTenant", resp, "Failure responding to request") + return + } + + return +} + +// ListByTenantPreparer prepares the ListByTenant request. +func (client BestPracticesClient) ListByTenantPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Automanage/bestPractices"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTenantSender sends the ListByTenant request. The method will close the +// http.Response Body if it receives an error. +func (client BestPracticesClient) ListByTenantSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByTenantResponder handles the response to the ListByTenant request. The method always +// closes the http.Response Body. +func (client BestPracticesClient) ListByTenantResponder(resp *http.Response) (result BestPracticeList, 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/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/bestpracticesversions.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/bestpracticesversions.go new file mode 100644 index 000000000000..a664fdde5a2a --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/bestpracticesversions.go @@ -0,0 +1,181 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" +) + +// BestPracticesVersionsClient is the automanage Client +type BestPracticesVersionsClient struct { + BaseClient +} + +// NewBestPracticesVersionsClient creates an instance of the BestPracticesVersionsClient client. +func NewBestPracticesVersionsClient(subscriptionID string) BestPracticesVersionsClient { + return NewBestPracticesVersionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBestPracticesVersionsClientWithBaseURI creates an instance of the BestPracticesVersionsClient 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 NewBestPracticesVersionsClientWithBaseURI(baseURI string, subscriptionID string) BestPracticesVersionsClient { + return BestPracticesVersionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get information about a Automanage best practice version +// Parameters: +// bestPracticeName - the Automanage best practice name. +// versionName - the Automanage best practice version name. +func (client BestPracticesVersionsClient) Get(ctx context.Context, bestPracticeName string, versionName string) (result BestPractice, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BestPracticesVersionsClient.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, bestPracticeName, versionName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.BestPracticesVersionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.BestPracticesVersionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.BestPracticesVersionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client BestPracticesVersionsClient) GetPreparer(ctx context.Context, bestPracticeName string, versionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "bestPracticeName": autorest.Encode("path", bestPracticeName), + "versionName": autorest.Encode("path", versionName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}/versions/{versionName}", 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 BestPracticesVersionsClient) 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 BestPracticesVersionsClient) GetResponder(resp *http.Response) (result BestPractice, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByTenant retrieve a list of Automanage best practices versions +// Parameters: +// bestPracticeName - the Automanage best practice name. +func (client BestPracticesVersionsClient) ListByTenant(ctx context.Context, bestPracticeName string) (result BestPracticeList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BestPracticesVersionsClient.ListByTenant") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByTenantPreparer(ctx, bestPracticeName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.BestPracticesVersionsClient", "ListByTenant", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTenantSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.BestPracticesVersionsClient", "ListByTenant", resp, "Failure sending request") + return + } + + result, err = client.ListByTenantResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.BestPracticesVersionsClient", "ListByTenant", resp, "Failure responding to request") + return + } + + return +} + +// ListByTenantPreparer prepares the ListByTenant request. +func (client BestPracticesVersionsClient) ListByTenantPreparer(ctx context.Context, bestPracticeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "bestPracticeName": autorest.Encode("path", bestPracticeName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Automanage/bestPractices/{bestPracticeName}/versions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTenantSender sends the ListByTenant request. The method will close the +// http.Response Body if it receives an error. +func (client BestPracticesVersionsClient) ListByTenantSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByTenantResponder handles the response to the ListByTenant request. The method always +// closes the http.Response Body. +func (client BestPracticesVersionsClient) ListByTenantResponder(resp *http.Response) (result BestPracticeList, 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/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/client.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/client.go new file mode 100644 index 000000000000..6f3c1e593838 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/client.go @@ -0,0 +1,41 @@ +// Package automanage implements the Azure ARM Automanage service API version 2022-05-04. +// +// Automanage Client +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Automanage + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Automanage. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofileassignments.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofileassignments.go new file mode 100644 index 000000000000..47a16dc052d4 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofileassignments.go @@ -0,0 +1,715 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "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" +) + +// ConfigurationProfileAssignmentsClient is the automanage Client +type ConfigurationProfileAssignmentsClient struct { + BaseClient +} + +// NewConfigurationProfileAssignmentsClient creates an instance of the ConfigurationProfileAssignmentsClient client. +func NewConfigurationProfileAssignmentsClient(subscriptionID string) ConfigurationProfileAssignmentsClient { + return NewConfigurationProfileAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationProfileAssignmentsClientWithBaseURI creates an instance of the ConfigurationProfileAssignmentsClient +// 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 NewConfigurationProfileAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationProfileAssignmentsClient { + return ConfigurationProfileAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates an association between a VM and Automanage configuration profile +// Parameters: +// configurationProfileAssignmentName - name of the configuration profile assignment. Only default is +// supported. +// parameters - parameters supplied to the create or update configuration profile assignment. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// VMName - the name of the virtual machine. +func (client ConfigurationProfileAssignmentsClient) CreateOrUpdate(ctx context.Context, configurationProfileAssignmentName string, parameters ConfigurationProfileAssignment, resourceGroupName string, VMName string) (result ConfigurationProfileAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileAssignmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileAssignmentsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, configurationProfileAssignmentName, parameters, resourceGroupName, VMName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConfigurationProfileAssignmentsClient) CreateOrUpdatePreparer(ctx context.Context, configurationProfileAssignmentName string, parameters ConfigurationProfileAssignment, resourceGroupName string, VMName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", VMName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ManagedBy = nil + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationProfileAssignmentsClient) 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 ConfigurationProfileAssignmentsClient) CreateOrUpdateResponder(resp *http.Response) (result ConfigurationProfileAssignment, 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 configuration profile assignment +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// configurationProfileAssignmentName - name of the configuration profile assignment +// VMName - the name of the virtual machine. +func (client ConfigurationProfileAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, configurationProfileAssignmentName string, VMName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileAssignmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileAssignmentsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, configurationProfileAssignmentName, VMName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConfigurationProfileAssignmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, configurationProfileAssignmentName string, VMName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", VMName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}", 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 ConfigurationProfileAssignmentsClient) 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 ConfigurationProfileAssignmentsClient) 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 information about a configuration profile assignment +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// configurationProfileAssignmentName - the configuration profile assignment name. +// VMName - the name of the virtual machine. +func (client ConfigurationProfileAssignmentsClient) Get(ctx context.Context, resourceGroupName string, configurationProfileAssignmentName string, VMName string) (result ConfigurationProfileAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileAssignmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileAssignmentsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, configurationProfileAssignmentName, VMName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationProfileAssignmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, configurationProfileAssignmentName string, VMName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", VMName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}", 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 ConfigurationProfileAssignmentsClient) 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 ConfigurationProfileAssignmentsClient) GetResponder(resp *http.Response) (result ConfigurationProfileAssignment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get list of configuration profile assignments +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ConfigurationProfileAssignmentsClient) List(ctx context.Context, resourceGroupName string) (result ConfigurationProfileAssignmentList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileAssignmentsClient.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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileAssignmentsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ConfigurationProfileAssignmentsClient) ListPreparer(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 = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfileAssignments", 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 ConfigurationProfileAssignmentsClient) 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 ConfigurationProfileAssignmentsClient) ListResponder(resp *http.Response) (result ConfigurationProfileAssignmentList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByClusterName get list of configuration profile assignments +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the Arc machine. +func (client ConfigurationProfileAssignmentsClient) ListByClusterName(ctx context.Context, resourceGroupName string, clusterName string) (result ConfigurationProfileAssignmentList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileAssignmentsClient.ListByClusterName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileAssignmentsClient", "ListByClusterName", err.Error()) + } + + req, err := client.ListByClusterNamePreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListByClusterName", nil, "Failure preparing request") + return + } + + resp, err := client.ListByClusterNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListByClusterName", resp, "Failure sending request") + return + } + + result, err = client.ListByClusterNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListByClusterName", resp, "Failure responding to request") + return + } + + return +} + +// ListByClusterNamePreparer prepares the ListByClusterName request. +func (client ConfigurationProfileAssignmentsClient) ListByClusterNamePreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByClusterNameSender sends the ListByClusterName request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationProfileAssignmentsClient) ListByClusterNameSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByClusterNameResponder handles the response to the ListByClusterName request. The method always +// closes the http.Response Body. +func (client ConfigurationProfileAssignmentsClient) ListByClusterNameResponder(resp *http.Response) (result ConfigurationProfileAssignmentList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByMachineName get list of configuration profile assignments +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// machineName - the name of the Arc machine. +func (client ConfigurationProfileAssignmentsClient) ListByMachineName(ctx context.Context, resourceGroupName string, machineName string) (result ConfigurationProfileAssignmentList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileAssignmentsClient.ListByMachineName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileAssignmentsClient", "ListByMachineName", err.Error()) + } + + req, err := client.ListByMachineNamePreparer(ctx, resourceGroupName, machineName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListByMachineName", nil, "Failure preparing request") + return + } + + resp, err := client.ListByMachineNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListByMachineName", resp, "Failure sending request") + return + } + + result, err = client.ListByMachineNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListByMachineName", resp, "Failure responding to request") + return + } + + return +} + +// ListByMachineNamePreparer prepares the ListByMachineName request. +func (client ConfigurationProfileAssignmentsClient) ListByMachineNamePreparer(ctx context.Context, resourceGroupName string, machineName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "machineName": autorest.Encode("path", machineName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByMachineNameSender sends the ListByMachineName request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationProfileAssignmentsClient) ListByMachineNameSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByMachineNameResponder handles the response to the ListByMachineName request. The method always +// closes the http.Response Body. +func (client ConfigurationProfileAssignmentsClient) ListByMachineNameResponder(resp *http.Response) (result ConfigurationProfileAssignmentList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription get list of configuration profile assignments under a given subscription +func (client ConfigurationProfileAssignmentsClient) ListBySubscription(ctx context.Context) (result ConfigurationProfileAssignmentList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileAssignmentsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileAssignmentsClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ConfigurationProfileAssignmentsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfileAssignments", 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 ConfigurationProfileAssignmentsClient) 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 ConfigurationProfileAssignmentsClient) ListBySubscriptionResponder(resp *http.Response) (result ConfigurationProfileAssignmentList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByVirtualMachines get list of configuration profile assignments +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// VMName - the name of the virtual machine. +func (client ConfigurationProfileAssignmentsClient) ListByVirtualMachines(ctx context.Context, resourceGroupName string, VMName string) (result ConfigurationProfileAssignmentList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileAssignmentsClient.ListByVirtualMachines") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileAssignmentsClient", "ListByVirtualMachines", err.Error()) + } + + req, err := client.ListByVirtualMachinesPreparer(ctx, resourceGroupName, VMName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListByVirtualMachines", nil, "Failure preparing request") + return + } + + resp, err := client.ListByVirtualMachinesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListByVirtualMachines", resp, "Failure sending request") + return + } + + result, err = client.ListByVirtualMachinesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileAssignmentsClient", "ListByVirtualMachines", resp, "Failure responding to request") + return + } + + return +} + +// ListByVirtualMachinesPreparer prepares the ListByVirtualMachines request. +func (client ConfigurationProfileAssignmentsClient) ListByVirtualMachinesPreparer(ctx context.Context, resourceGroupName string, VMName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", VMName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByVirtualMachinesSender sends the ListByVirtualMachines request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationProfileAssignmentsClient) ListByVirtualMachinesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByVirtualMachinesResponder handles the response to the ListByVirtualMachines request. The method always +// closes the http.Response Body. +func (client ConfigurationProfileAssignmentsClient) ListByVirtualMachinesResponder(resp *http.Response) (result ConfigurationProfileAssignmentList, 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/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofilehciassignments.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofilehciassignments.go new file mode 100644 index 000000000000..7ef8c7a85fe3 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofilehciassignments.go @@ -0,0 +1,301 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "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" +) + +// ConfigurationProfileHCIAssignmentsClient is the automanage Client +type ConfigurationProfileHCIAssignmentsClient struct { + BaseClient +} + +// NewConfigurationProfileHCIAssignmentsClient creates an instance of the ConfigurationProfileHCIAssignmentsClient +// client. +func NewConfigurationProfileHCIAssignmentsClient(subscriptionID string) ConfigurationProfileHCIAssignmentsClient { + return NewConfigurationProfileHCIAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationProfileHCIAssignmentsClientWithBaseURI creates an instance of the +// ConfigurationProfileHCIAssignmentsClient 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 NewConfigurationProfileHCIAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationProfileHCIAssignmentsClient { + return ConfigurationProfileHCIAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates an association between a AzureStackHCI cluster and Automanage configuration profile +// Parameters: +// parameters - parameters supplied to the create or update configuration profile assignment. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the Arc machine. +// configurationProfileAssignmentName - name of the configuration profile assignment. Only default is +// supported. +func (client ConfigurationProfileHCIAssignmentsClient) CreateOrUpdate(ctx context.Context, parameters ConfigurationProfileAssignment, resourceGroupName string, clusterName string, configurationProfileAssignmentName string) (result ConfigurationProfileAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileHCIAssignmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileHCIAssignmentsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, parameters, resourceGroupName, clusterName, configurationProfileAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCIAssignmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCIAssignmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCIAssignmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConfigurationProfileHCIAssignmentsClient) CreateOrUpdatePreparer(ctx context.Context, parameters ConfigurationProfileAssignment, resourceGroupName string, clusterName string, configurationProfileAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ManagedBy = nil + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationProfileHCIAssignmentsClient) 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 ConfigurationProfileHCIAssignmentsClient) CreateOrUpdateResponder(resp *http.Response) (result ConfigurationProfileAssignment, 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 configuration profile assignment +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the Arc machine. +// configurationProfileAssignmentName - name of the configuration profile assignment +func (client ConfigurationProfileHCIAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, configurationProfileAssignmentName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileHCIAssignmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileHCIAssignmentsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName, configurationProfileAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCIAssignmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCIAssignmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCIAssignmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConfigurationProfileHCIAssignmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string, configurationProfileAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}", 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 ConfigurationProfileHCIAssignmentsClient) 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 ConfigurationProfileHCIAssignmentsClient) 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 information about a configuration profile assignment +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the Arc machine. +// configurationProfileAssignmentName - the configuration profile assignment name. +func (client ConfigurationProfileHCIAssignmentsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, configurationProfileAssignmentName string) (result ConfigurationProfileAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileHCIAssignmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileHCIAssignmentsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName, configurationProfileAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCIAssignmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCIAssignmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCIAssignmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationProfileHCIAssignmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string, configurationProfileAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}", 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 ConfigurationProfileHCIAssignmentsClient) 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 ConfigurationProfileHCIAssignmentsClient) GetResponder(resp *http.Response) (result ConfigurationProfileAssignment, 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/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofilehcrpassignments.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofilehcrpassignments.go new file mode 100644 index 000000000000..e44b59f9e384 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofilehcrpassignments.go @@ -0,0 +1,301 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "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" +) + +// ConfigurationProfileHCRPAssignmentsClient is the automanage Client +type ConfigurationProfileHCRPAssignmentsClient struct { + BaseClient +} + +// NewConfigurationProfileHCRPAssignmentsClient creates an instance of the ConfigurationProfileHCRPAssignmentsClient +// client. +func NewConfigurationProfileHCRPAssignmentsClient(subscriptionID string) ConfigurationProfileHCRPAssignmentsClient { + return NewConfigurationProfileHCRPAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationProfileHCRPAssignmentsClientWithBaseURI creates an instance of the +// ConfigurationProfileHCRPAssignmentsClient 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 NewConfigurationProfileHCRPAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationProfileHCRPAssignmentsClient { + return ConfigurationProfileHCRPAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates an association between a ARC machine and Automanage configuration profile +// Parameters: +// parameters - parameters supplied to the create or update configuration profile assignment. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// machineName - the name of the Arc machine. +// configurationProfileAssignmentName - name of the configuration profile assignment. Only default is +// supported. +func (client ConfigurationProfileHCRPAssignmentsClient) CreateOrUpdate(ctx context.Context, parameters ConfigurationProfileAssignment, resourceGroupName string, machineName string, configurationProfileAssignmentName string) (result ConfigurationProfileAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileHCRPAssignmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileHCRPAssignmentsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, parameters, resourceGroupName, machineName, configurationProfileAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCRPAssignmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCRPAssignmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCRPAssignmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConfigurationProfileHCRPAssignmentsClient) CreateOrUpdatePreparer(ctx context.Context, parameters ConfigurationProfileAssignment, resourceGroupName string, machineName string, configurationProfileAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "machineName": autorest.Encode("path", machineName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ManagedBy = nil + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationProfileHCRPAssignmentsClient) 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 ConfigurationProfileHCRPAssignmentsClient) CreateOrUpdateResponder(resp *http.Response) (result ConfigurationProfileAssignment, 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 configuration profile assignment +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// machineName - the name of the Arc machine. +// configurationProfileAssignmentName - name of the configuration profile assignment +func (client ConfigurationProfileHCRPAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, machineName string, configurationProfileAssignmentName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileHCRPAssignmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileHCRPAssignmentsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, machineName, configurationProfileAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCRPAssignmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCRPAssignmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCRPAssignmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConfigurationProfileHCRPAssignmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, machineName string, configurationProfileAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "machineName": autorest.Encode("path", machineName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}", 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 ConfigurationProfileHCRPAssignmentsClient) 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 ConfigurationProfileHCRPAssignmentsClient) 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 information about a configuration profile assignment +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// machineName - the name of the Arc machine. +// configurationProfileAssignmentName - the configuration profile assignment name. +func (client ConfigurationProfileHCRPAssignmentsClient) Get(ctx context.Context, resourceGroupName string, machineName string, configurationProfileAssignmentName string) (result ConfigurationProfileAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfileHCRPAssignmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfileHCRPAssignmentsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, machineName, configurationProfileAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCRPAssignmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCRPAssignmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfileHCRPAssignmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationProfileHCRPAssignmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, machineName string, configurationProfileAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "machineName": autorest.Encode("path", machineName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}", 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 ConfigurationProfileHCRPAssignmentsClient) 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 ConfigurationProfileHCRPAssignmentsClient) GetResponder(resp *http.Response) (result ConfigurationProfileAssignment, 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/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofiles.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofiles.go new file mode 100644 index 000000000000..d26336dae0dc --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofiles.go @@ -0,0 +1,540 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "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" +) + +// ConfigurationProfilesClient is the automanage Client +type ConfigurationProfilesClient struct { + BaseClient +} + +// NewConfigurationProfilesClient creates an instance of the ConfigurationProfilesClient client. +func NewConfigurationProfilesClient(subscriptionID string) ConfigurationProfilesClient { + return NewConfigurationProfilesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationProfilesClientWithBaseURI creates an instance of the ConfigurationProfilesClient 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 NewConfigurationProfilesClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationProfilesClient { + return ConfigurationProfilesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a configuration profile +// Parameters: +// configurationProfileName - name of the configuration profile. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// parameters - parameters supplied to create or update configuration profile. +func (client ConfigurationProfilesClient) CreateOrUpdate(ctx context.Context, configurationProfileName string, resourceGroupName string, parameters ConfigurationProfile) (result ConfigurationProfile, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfilesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfilesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, configurationProfileName, resourceGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConfigurationProfilesClient) CreateOrUpdatePreparer(ctx context.Context, configurationProfileName string, resourceGroupName string, parameters ConfigurationProfile) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileName": autorest.Encode("path", configurationProfileName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationProfilesClient) 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 ConfigurationProfilesClient) CreateOrUpdateResponder(resp *http.Response) (result ConfigurationProfile, 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 configuration profile +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// configurationProfileName - name of the configuration profile +func (client ConfigurationProfilesClient) Delete(ctx context.Context, resourceGroupName string, configurationProfileName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfilesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfilesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, configurationProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConfigurationProfilesClient) DeletePreparer(ctx context.Context, resourceGroupName string, configurationProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileName": autorest.Encode("path", configurationProfileName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}", 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 ConfigurationProfilesClient) 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 ConfigurationProfilesClient) 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 information about a configuration profile +// Parameters: +// configurationProfileName - the configuration profile name. +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ConfigurationProfilesClient) Get(ctx context.Context, configurationProfileName string, resourceGroupName string) (result ConfigurationProfile, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfilesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfilesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, configurationProfileName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationProfilesClient) GetPreparer(ctx context.Context, configurationProfileName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileName": autorest.Encode("path", configurationProfileName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}", 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 ConfigurationProfilesClient) 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 ConfigurationProfilesClient) GetResponder(resp *http.Response) (result ConfigurationProfile, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup retrieve a list of configuration profile within a given resource group +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ConfigurationProfilesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ConfigurationProfileList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfilesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfilesClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ConfigurationProfilesClient) 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 = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles", 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 ConfigurationProfilesClient) 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 ConfigurationProfilesClient) ListByResourceGroupResponder(resp *http.Response) (result ConfigurationProfileList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription retrieve a list of configuration profile within a subscription +func (client ConfigurationProfilesClient) ListBySubscription(ctx context.Context) (result ConfigurationProfileList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfilesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfilesClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ConfigurationProfilesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfiles", 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 ConfigurationProfilesClient) 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 ConfigurationProfilesClient) ListBySubscriptionResponder(resp *http.Response) (result ConfigurationProfileList, 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 configuration profile +// Parameters: +// configurationProfileName - name of the configuration profile. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// parameters - parameters supplied to update configuration profile. +func (client ConfigurationProfilesClient) Update(ctx context.Context, configurationProfileName string, resourceGroupName string, parameters ConfigurationProfileUpdate) (result ConfigurationProfile, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfilesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfilesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, configurationProfileName, resourceGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ConfigurationProfilesClient) UpdatePreparer(ctx context.Context, configurationProfileName string, resourceGroupName string, parameters ConfigurationProfileUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileName": autorest.Encode("path", configurationProfileName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + 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.Automanage/configurationProfiles/{configurationProfileName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationProfilesClient) 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 ConfigurationProfilesClient) UpdateResponder(resp *http.Response) (result ConfigurationProfile, 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/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofilesversions.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofilesversions.go new file mode 100644 index 000000000000..0e9b7e209119 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/configurationprofilesversions.go @@ -0,0 +1,383 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "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" +) + +// ConfigurationProfilesVersionsClient is the automanage Client +type ConfigurationProfilesVersionsClient struct { + BaseClient +} + +// NewConfigurationProfilesVersionsClient creates an instance of the ConfigurationProfilesVersionsClient client. +func NewConfigurationProfilesVersionsClient(subscriptionID string) ConfigurationProfilesVersionsClient { + return NewConfigurationProfilesVersionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationProfilesVersionsClientWithBaseURI creates an instance of the ConfigurationProfilesVersionsClient +// 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 NewConfigurationProfilesVersionsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationProfilesVersionsClient { + return ConfigurationProfilesVersionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a configuration profile version +// Parameters: +// configurationProfileName - name of the configuration profile. +// versionName - the configuration profile version name. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// parameters - parameters supplied to create or update configuration profile. +func (client ConfigurationProfilesVersionsClient) CreateOrUpdate(ctx context.Context, configurationProfileName string, versionName string, resourceGroupName string, parameters ConfigurationProfile) (result ConfigurationProfile, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfilesVersionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfilesVersionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, configurationProfileName, versionName, resourceGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConfigurationProfilesVersionsClient) CreateOrUpdatePreparer(ctx context.Context, configurationProfileName string, versionName string, resourceGroupName string, parameters ConfigurationProfile) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileName": autorest.Encode("path", configurationProfileName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "versionName": autorest.Encode("path", versionName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationProfilesVersionsClient) 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 ConfigurationProfilesVersionsClient) CreateOrUpdateResponder(resp *http.Response) (result ConfigurationProfile, 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 configuration profile version +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// configurationProfileName - name of the configuration profile +// versionName - the configuration profile version name. +func (client ConfigurationProfilesVersionsClient) Delete(ctx context.Context, resourceGroupName string, configurationProfileName string, versionName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfilesVersionsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfilesVersionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, configurationProfileName, versionName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConfigurationProfilesVersionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, configurationProfileName string, versionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileName": autorest.Encode("path", configurationProfileName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "versionName": autorest.Encode("path", versionName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}", 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 ConfigurationProfilesVersionsClient) 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 ConfigurationProfilesVersionsClient) 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 information about a configuration profile version +// Parameters: +// configurationProfileName - the configuration profile name. +// versionName - the configuration profile version name. +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ConfigurationProfilesVersionsClient) Get(ctx context.Context, configurationProfileName string, versionName string, resourceGroupName string) (result ConfigurationProfile, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfilesVersionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfilesVersionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, configurationProfileName, versionName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationProfilesVersionsClient) GetPreparer(ctx context.Context, configurationProfileName string, versionName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileName": autorest.Encode("path", configurationProfileName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "versionName": autorest.Encode("path", versionName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}", 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 ConfigurationProfilesVersionsClient) 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 ConfigurationProfilesVersionsClient) GetResponder(resp *http.Response) (result ConfigurationProfile, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListChildResources retrieve a list of configuration profile version for a configuration profile +// Parameters: +// configurationProfileName - name of the configuration profile. +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ConfigurationProfilesVersionsClient) ListChildResources(ctx context.Context, configurationProfileName string, resourceGroupName string) (result ConfigurationProfileList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationProfilesVersionsClient.ListChildResources") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ConfigurationProfilesVersionsClient", "ListChildResources", err.Error()) + } + + req, err := client.ListChildResourcesPreparer(ctx, configurationProfileName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "ListChildResources", nil, "Failure preparing request") + return + } + + resp, err := client.ListChildResourcesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "ListChildResources", resp, "Failure sending request") + return + } + + result, err = client.ListChildResourcesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ConfigurationProfilesVersionsClient", "ListChildResources", resp, "Failure responding to request") + return + } + + return +} + +// ListChildResourcesPreparer prepares the ListChildResources request. +func (client ConfigurationProfilesVersionsClient) ListChildResourcesPreparer(ctx context.Context, configurationProfileName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileName": autorest.Encode("path", configurationProfileName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListChildResourcesSender sends the ListChildResources request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationProfilesVersionsClient) ListChildResourcesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListChildResourcesResponder handles the response to the ListChildResources request. The method always +// closes the http.Response Body. +func (client ConfigurationProfilesVersionsClient) ListChildResourcesResponder(resp *http.Response) (result ConfigurationProfileList, 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/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/enums.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/enums.go new file mode 100644 index 000000000000..05c95d21aa3e --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/enums.go @@ -0,0 +1,56 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// ActionType enumerates the values for action type. +type ActionType string + +const ( + // ActionTypeInternal ... + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns an array of possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ActionTypeInternal} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // CreatedByTypeApplication ... + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey ... + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity ... + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser ... + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} +} + +// Origin enumerates the values for origin. +type Origin string + +const ( + // OriginSystem ... + OriginSystem Origin = "system" + // OriginUser ... + OriginUser Origin = "user" + // OriginUsersystem ... + OriginUsersystem Origin = "user,system" +) + +// PossibleOriginValues returns an array of possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{OriginSystem, OriginUser, OriginUsersystem} +} diff --git a/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/hcireports.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/hcireports.go new file mode 100644 index 000000000000..46045c12af53 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/hcireports.go @@ -0,0 +1,209 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "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" +) + +// HCIReportsClient is the automanage Client +type HCIReportsClient struct { + BaseClient +} + +// NewHCIReportsClient creates an instance of the HCIReportsClient client. +func NewHCIReportsClient(subscriptionID string) HCIReportsClient { + return NewHCIReportsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewHCIReportsClientWithBaseURI creates an instance of the HCIReportsClient 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 NewHCIReportsClientWithBaseURI(baseURI string, subscriptionID string) HCIReportsClient { + return HCIReportsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get information about a report associated with a configuration profile assignment run +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the Arc machine. +// configurationProfileAssignmentName - the configuration profile assignment name. +// reportName - the report name. +func (client HCIReportsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, configurationProfileAssignmentName string, reportName string) (result Report, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HCIReportsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.HCIReportsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName, configurationProfileAssignmentName, reportName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.HCIReportsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.HCIReportsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.HCIReportsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client HCIReportsClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string, configurationProfileAssignmentName string, reportName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "reportName": autorest.Encode("path", reportName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}", 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 HCIReportsClient) 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 HCIReportsClient) GetResponder(resp *http.Response) (result Report, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByConfigurationProfileAssignments retrieve a list of reports within a given configuration profile assignment +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the Arc machine. +// configurationProfileAssignmentName - the configuration profile assignment name. +func (client HCIReportsClient) ListByConfigurationProfileAssignments(ctx context.Context, resourceGroupName string, clusterName string, configurationProfileAssignmentName string) (result ReportList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HCIReportsClient.ListByConfigurationProfileAssignments") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.HCIReportsClient", "ListByConfigurationProfileAssignments", err.Error()) + } + + req, err := client.ListByConfigurationProfileAssignmentsPreparer(ctx, resourceGroupName, clusterName, configurationProfileAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.HCIReportsClient", "ListByConfigurationProfileAssignments", nil, "Failure preparing request") + return + } + + resp, err := client.ListByConfigurationProfileAssignmentsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.HCIReportsClient", "ListByConfigurationProfileAssignments", resp, "Failure sending request") + return + } + + result, err = client.ListByConfigurationProfileAssignmentsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.HCIReportsClient", "ListByConfigurationProfileAssignments", resp, "Failure responding to request") + return + } + + return +} + +// ListByConfigurationProfileAssignmentsPreparer prepares the ListByConfigurationProfileAssignments request. +func (client HCIReportsClient) ListByConfigurationProfileAssignmentsPreparer(ctx context.Context, resourceGroupName string, clusterName string, configurationProfileAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByConfigurationProfileAssignmentsSender sends the ListByConfigurationProfileAssignments request. The method will close the +// http.Response Body if it receives an error. +func (client HCIReportsClient) ListByConfigurationProfileAssignmentsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByConfigurationProfileAssignmentsResponder handles the response to the ListByConfigurationProfileAssignments request. The method always +// closes the http.Response Body. +func (client HCIReportsClient) ListByConfigurationProfileAssignmentsResponder(resp *http.Response) (result ReportList, 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/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/hcrpreports.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/hcrpreports.go new file mode 100644 index 000000000000..c9e7db65e02b --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/hcrpreports.go @@ -0,0 +1,209 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "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" +) + +// HCRPReportsClient is the automanage Client +type HCRPReportsClient struct { + BaseClient +} + +// NewHCRPReportsClient creates an instance of the HCRPReportsClient client. +func NewHCRPReportsClient(subscriptionID string) HCRPReportsClient { + return NewHCRPReportsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewHCRPReportsClientWithBaseURI creates an instance of the HCRPReportsClient 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 NewHCRPReportsClientWithBaseURI(baseURI string, subscriptionID string) HCRPReportsClient { + return HCRPReportsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get information about a report associated with a configuration profile assignment run +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// machineName - the name of the Arc machine. +// configurationProfileAssignmentName - the configuration profile assignment name. +// reportName - the report name. +func (client HCRPReportsClient) Get(ctx context.Context, resourceGroupName string, machineName string, configurationProfileAssignmentName string, reportName string) (result Report, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HCRPReportsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.HCRPReportsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, machineName, configurationProfileAssignmentName, reportName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.HCRPReportsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.HCRPReportsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.HCRPReportsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client HCRPReportsClient) GetPreparer(ctx context.Context, resourceGroupName string, machineName string, configurationProfileAssignmentName string, reportName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "machineName": autorest.Encode("path", machineName), + "reportName": autorest.Encode("path", reportName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}", 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 HCRPReportsClient) 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 HCRPReportsClient) GetResponder(resp *http.Response) (result Report, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByConfigurationProfileAssignments retrieve a list of reports within a given configuration profile assignment +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// machineName - the name of the Arc machine. +// configurationProfileAssignmentName - the configuration profile assignment name. +func (client HCRPReportsClient) ListByConfigurationProfileAssignments(ctx context.Context, resourceGroupName string, machineName string, configurationProfileAssignmentName string) (result ReportList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HCRPReportsClient.ListByConfigurationProfileAssignments") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.HCRPReportsClient", "ListByConfigurationProfileAssignments", err.Error()) + } + + req, err := client.ListByConfigurationProfileAssignmentsPreparer(ctx, resourceGroupName, machineName, configurationProfileAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.HCRPReportsClient", "ListByConfigurationProfileAssignments", nil, "Failure preparing request") + return + } + + resp, err := client.ListByConfigurationProfileAssignmentsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.HCRPReportsClient", "ListByConfigurationProfileAssignments", resp, "Failure sending request") + return + } + + result, err = client.ListByConfigurationProfileAssignmentsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.HCRPReportsClient", "ListByConfigurationProfileAssignments", resp, "Failure responding to request") + return + } + + return +} + +// ListByConfigurationProfileAssignmentsPreparer prepares the ListByConfigurationProfileAssignments request. +func (client HCRPReportsClient) ListByConfigurationProfileAssignmentsPreparer(ctx context.Context, resourceGroupName string, machineName string, configurationProfileAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "machineName": autorest.Encode("path", machineName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByConfigurationProfileAssignmentsSender sends the ListByConfigurationProfileAssignments request. The method will close the +// http.Response Body if it receives an error. +func (client HCRPReportsClient) ListByConfigurationProfileAssignmentsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByConfigurationProfileAssignmentsResponder handles the response to the ListByConfigurationProfileAssignments request. The method always +// closes the http.Response Body. +func (client HCRPReportsClient) ListByConfigurationProfileAssignmentsResponder(resp *http.Response) (result ReportList, 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/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/models.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/models.go new file mode 100644 index 000000000000..4827b1e5ae4e --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/models.go @@ -0,0 +1,507 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "encoding/json" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" +) + +// The package's fully qualified name. +const fqdn = "home/runner/work/kermit/kermit/sdk/automanage/2022-05-04/automanage" + +// AssignmentReportProperties data related to the report detail. +type AssignmentReportProperties struct { + // StartTime - Start time of the configuration profile assignment processing. + StartTime *string `json:"startTime,omitempty"` + // EndTime - End time of the configuration profile assignment processing. + EndTime *string `json:"endTime,omitempty"` + // LastModifiedTime - READ-ONLY; Last modified time of the configuration profile assignment processing. + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + // Duration - READ-ONLY; Duration of the configuration profile assignment processing. + Duration *string `json:"duration,omitempty"` + // Type - READ-ONLY; Type of the configuration profile assignment processing (Initial/Consistency). + Type *string `json:"type,omitempty"` + // Status - READ-ONLY; The status of the configuration profile assignment. + Status *string `json:"status,omitempty"` + // ConfigurationProfile - READ-ONLY; The configurationProfile linked to the assignment. + ConfigurationProfile *string `json:"configurationProfile,omitempty"` + // Resources - READ-ONLY; List of resources processed by the configuration profile assignment. + Resources *[]ReportResource `json:"resources,omitempty"` + // Error - READ-ONLY; Error message, if any, returned by the configuration profile assignment processing. + Error *ErrorDetail `json:"error,omitempty"` + // ReportFormatVersion - READ-ONLY; Version of the report format + ReportFormatVersion *string `json:"reportFormatVersion,omitempty"` +} + +// MarshalJSON is the custom marshaler for AssignmentReportProperties. +func (arp AssignmentReportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arp.StartTime != nil { + objectMap["startTime"] = arp.StartTime + } + if arp.EndTime != nil { + objectMap["endTime"] = arp.EndTime + } + return json.Marshal(objectMap) +} + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureEntityResource. +func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// BestPractice definition of the Automanage best practice. +type BestPractice struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The fully qualified ID for the best practice. For example, /providers/Microsoft.Automanage/bestPractices/azureBestPracticesProduction + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The type of the resource. For example, Microsoft.Automanage/bestPractices + Type *string `json:"type,omitempty"` + // Name - READ-ONLY; The name of the best practice. For example, azureBestPracticesProduction + Name *string `json:"name,omitempty"` + // Properties - Properties of the best practice. + Properties *ConfigurationProfileProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for BestPractice. +func (bp BestPractice) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bp.Properties != nil { + objectMap["properties"] = bp.Properties + } + return json.Marshal(objectMap) +} + +// BestPracticeList the response of the list best practice operation. +type BestPracticeList struct { + autorest.Response `json:"-"` + // Value - Result of the list best practice operation. + Value *[]BestPractice `json:"value,omitempty"` +} + +// ConfigurationProfile definition of the configuration profile. +type ConfigurationProfile struct { + autorest.Response `json:"-"` + // Properties - Properties of the configuration profile. + Properties *ConfigurationProfileProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationProfile. +func (cp ConfigurationProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.Properties != nil { + objectMap["properties"] = cp.Properties + } + if cp.Tags != nil { + objectMap["tags"] = cp.Tags + } + if cp.Location != nil { + objectMap["location"] = cp.Location + } + return json.Marshal(objectMap) +} + +// ConfigurationProfileAssignment configuration profile assignment is an association between a VM and +// automanage profile configuration. +type ConfigurationProfileAssignment struct { + autorest.Response `json:"-"` + // Properties - Properties of the configuration profile assignment. + Properties *ConfigurationProfileAssignmentProperties `json:"properties,omitempty"` + // ManagedBy - READ-ONLY; Azure resource id. Indicates if this resource is managed by another Azure resource. + ManagedBy *string `json:"managedBy,omitempty"` + // SystemData - READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationProfileAssignment. +func (cpa ConfigurationProfileAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cpa.Properties != nil { + objectMap["properties"] = cpa.Properties + } + return json.Marshal(objectMap) +} + +// ConfigurationProfileAssignmentList the response of the list configuration profile assignment operation. +type ConfigurationProfileAssignmentList struct { + autorest.Response `json:"-"` + // Value - Result of the list configuration profile assignment operation. + Value *[]ConfigurationProfileAssignment `json:"value,omitempty"` +} + +// ConfigurationProfileAssignmentProperties automanage configuration profile assignment properties. +type ConfigurationProfileAssignmentProperties struct { + // ConfigurationProfile - The Automanage configurationProfile ARM Resource URI. + ConfigurationProfile *string `json:"configurationProfile,omitempty"` + // TargetID - READ-ONLY; The target VM resource URI + TargetID *string `json:"targetId,omitempty"` + // Status - READ-ONLY; The status of onboarding, which only appears in the response. + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationProfileAssignmentProperties. +func (cpap ConfigurationProfileAssignmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cpap.ConfigurationProfile != nil { + objectMap["configurationProfile"] = cpap.ConfigurationProfile + } + return json.Marshal(objectMap) +} + +// ConfigurationProfileList the response of the list configuration profile operation. +type ConfigurationProfileList struct { + autorest.Response `json:"-"` + // Value - Result of the list ConfigurationProfile operation. + Value *[]ConfigurationProfile `json:"value,omitempty"` +} + +// ConfigurationProfileProperties automanage configuration profile properties. +type ConfigurationProfileProperties struct { + // Configuration - configuration dictionary of the configuration profile. + Configuration interface{} `json:"configuration,omitempty"` +} + +// ConfigurationProfileUpdate definition of the configuration profile. +type ConfigurationProfileUpdate struct { + // Properties - Properties of the configuration profile. + Properties *ConfigurationProfileProperties `json:"properties,omitempty"` + // Tags - The tags of the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ConfigurationProfileUpdate. +func (CPU ConfigurationProfileUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if CPU.Properties != nil { + objectMap["properties"] = CPU.Properties + } + if CPU.Tags != nil { + objectMap["tags"] = CPU.Tags + } + return json.Marshal(objectMap) +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.). +type ErrorResponse struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// Operation details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Name - READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty"` + // IsDataAction - READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". Possible values include: 'OriginUser', 'OriginSystem', 'OriginUsersystem' + Origin Origin `json:"origin,omitempty"` + // ActionType - READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. Possible values include: 'ActionTypeInternal' + ActionType ActionType `json:"actionType,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 localized display information for this particular operation. +type OperationDisplay struct { + // Provider - READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult a list of REST API operations supported by an Azure Resource Provider. It contains +// an URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of operations supported by the resource provider + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Report definition of the report. +type Report struct { + autorest.Response `json:"-"` + // Properties - The properties for the report. + Properties *AssignmentReportProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Report. +func (r Report) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Properties != nil { + objectMap["properties"] = r.Properties + } + return json.Marshal(objectMap) +} + +// ReportList the response of the list report operation. +type ReportList struct { + autorest.Response `json:"-"` + // Value - Result of the list report operation. + Value *[]Report `json:"value,omitempty"` +} + +// ReportResource details about the resource processed by the configuration profile assignment +type ReportResource struct { + // Name - READ-ONLY; Name of the resource. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; ARM id of the resource. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Type of the resource. + Type *string `json:"type,omitempty"` + // Status - READ-ONLY; Status of the resource. + Status *string `json:"status,omitempty"` + // Error - READ-ONLY; Error message, if any, returned when deploying the resource. + Error *ErrorDetail `json:"error,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReportResource. +func (rr ReportResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServicePrincipal the Service Principal Id for the subscription. +type ServicePrincipal struct { + autorest.Response `json:"-"` + // Properties - The Service Principal properties for the subscription + Properties *ServicePrincipalProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicePrincipal. +func (sp ServicePrincipal) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.Properties != nil { + objectMap["properties"] = sp.Properties + } + return json.Marshal(objectMap) +} + +// ServicePrincipalListResult the list of ServicePrincipals. +type ServicePrincipalListResult struct { + autorest.Response `json:"-"` + // Value - The list of servicePrincipals. + Value *[]ServicePrincipal `json:"value,omitempty"` +} + +// ServicePrincipalProperties the Service Principal properties for the subscription. +type ServicePrincipalProperties struct { + // ServicePrincipalID - READ-ONLY; The Service Principal Id for the subscription. + ServicePrincipalID *string `json:"servicePrincipalId,omitempty"` + // AuthorizationSet - READ-ONLY; Returns the contributor RBAC Role exist or not for the Service Principal Id. + AuthorizationSet *bool `json:"authorizationSet,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicePrincipalProperties. +func (spp ServicePrincipalProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// UpdateResource represents an update resource +type UpdateResource struct { + // Tags - The tags of the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for UpdateResource. +func (ur UpdateResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ur.Tags != nil { + objectMap["tags"] = ur.Tags + } + return json.Marshal(objectMap) +} diff --git a/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/operations.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/operations.go new file mode 100644 index 000000000000..072c953b57aa --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/operations.go @@ -0,0 +1,99 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" +) + +// OperationsClient is the automanage Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Automanage REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.OperationsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Automanage/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/reports.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/reports.go new file mode 100644 index 000000000000..c84277c676d1 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/reports.go @@ -0,0 +1,209 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "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" +) + +// ReportsClient is the automanage Client +type ReportsClient struct { + BaseClient +} + +// NewReportsClient creates an instance of the ReportsClient client. +func NewReportsClient(subscriptionID string) ReportsClient { + return NewReportsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewReportsClientWithBaseURI creates an instance of the ReportsClient 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 NewReportsClientWithBaseURI(baseURI string, subscriptionID string) ReportsClient { + return ReportsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get information about a report associated with a configuration profile assignment run +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// configurationProfileAssignmentName - the configuration profile assignment name. +// reportName - the report name. +// VMName - the name of the virtual machine. +func (client ReportsClient) Get(ctx context.Context, resourceGroupName string, configurationProfileAssignmentName string, reportName string, VMName string) (result Report, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ReportsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, configurationProfileAssignmentName, reportName, VMName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ReportsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ReportsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ReportsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReportsClient) GetPreparer(ctx context.Context, resourceGroupName string, configurationProfileAssignmentName string, reportName string, VMName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "reportName": autorest.Encode("path", reportName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", VMName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports/{reportName}", 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 ReportsClient) 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 ReportsClient) GetResponder(resp *http.Response) (result Report, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByConfigurationProfileAssignments retrieve a list of reports within a given configuration profile assignment +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// configurationProfileAssignmentName - the configuration profile assignment name. +// VMName - the name of the virtual machine. +func (client ReportsClient) ListByConfigurationProfileAssignments(ctx context.Context, resourceGroupName string, configurationProfileAssignmentName string, VMName string) (result ReportList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReportsClient.ListByConfigurationProfileAssignments") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ReportsClient", "ListByConfigurationProfileAssignments", err.Error()) + } + + req, err := client.ListByConfigurationProfileAssignmentsPreparer(ctx, resourceGroupName, configurationProfileAssignmentName, VMName) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ReportsClient", "ListByConfigurationProfileAssignments", nil, "Failure preparing request") + return + } + + resp, err := client.ListByConfigurationProfileAssignmentsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ReportsClient", "ListByConfigurationProfileAssignments", resp, "Failure sending request") + return + } + + result, err = client.ListByConfigurationProfileAssignmentsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ReportsClient", "ListByConfigurationProfileAssignments", resp, "Failure responding to request") + return + } + + return +} + +// ListByConfigurationProfileAssignmentsPreparer prepares the ListByConfigurationProfileAssignments request. +func (client ReportsClient) ListByConfigurationProfileAssignmentsPreparer(ctx context.Context, resourceGroupName string, configurationProfileAssignmentName string, VMName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationProfileAssignmentName": autorest.Encode("path", configurationProfileAssignmentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", VMName), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}/reports", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByConfigurationProfileAssignmentsSender sends the ListByConfigurationProfileAssignments request. The method will close the +// http.Response Body if it receives an error. +func (client ReportsClient) ListByConfigurationProfileAssignmentsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByConfigurationProfileAssignmentsResponder handles the response to the ListByConfigurationProfileAssignments request. The method always +// closes the http.Response Body. +func (client ReportsClient) ListByConfigurationProfileAssignmentsResponder(resp *http.Response) (result ReportList, 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/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/serviceprincipals.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/serviceprincipals.go new file mode 100644 index 000000000000..d72001b77795 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/serviceprincipals.go @@ -0,0 +1,188 @@ +package automanage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "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" +) + +// ServicePrincipalsClient is the automanage Client +type ServicePrincipalsClient struct { + BaseClient +} + +// NewServicePrincipalsClient creates an instance of the ServicePrincipalsClient client. +func NewServicePrincipalsClient(subscriptionID string) ServicePrincipalsClient { + return NewServicePrincipalsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServicePrincipalsClientWithBaseURI creates an instance of the ServicePrincipalsClient 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 NewServicePrincipalsClientWithBaseURI(baseURI string, subscriptionID string) ServicePrincipalsClient { + return ServicePrincipalsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the Automanage AAD first party Application Service Principal details for the subscription id. +func (client ServicePrincipalsClient) Get(ctx context.Context) (result ServicePrincipal, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicePrincipalsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ServicePrincipalsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ServicePrincipalsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ServicePrincipalsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ServicePrincipalsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServicePrincipalsClient) GetPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/servicePrincipals/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 ServicePrincipalsClient) 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 ServicePrincipalsClient) GetResponder(resp *http.Response) (result ServicePrincipal, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription get the Automanage AAD first party Application Service Principal details for the subscription id. +func (client ServicePrincipalsClient) ListBySubscription(ctx context.Context) (result ServicePrincipalListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicePrincipalsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("automanage.ServicePrincipalsClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ServicePrincipalsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "automanage.ServicePrincipalsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "automanage.ServicePrincipalsClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ServicePrincipalsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-04" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/servicePrincipals", 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 ServicePrincipalsClient) 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 ServicePrincipalsClient) ListBySubscriptionResponder(resp *http.Response) (result ServicePrincipalListResult, 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/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/version.go b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/version.go new file mode 100644 index 000000000000..80eddeb41231 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage/version.go @@ -0,0 +1,19 @@ +package automanage + +import "github.com/tombuildsstuff/kermit/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "tombuildsstuff/kermit/" + Version() + " automanage/2022-05-04" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/modules.txt b/vendor/modules.txt index ca1940e95aca..2f643c5d7748 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -826,6 +826,7 @@ github.com/tombuildsstuff/giovanni/version github.com/tombuildsstuff/kermit/sdk/appconfiguration/1.0/appconfiguration github.com/tombuildsstuff/kermit/sdk/appplatform/2022-11-01-preview/appplatform github.com/tombuildsstuff/kermit/sdk/attestation/2022-08-01/attestation +github.com/tombuildsstuff/kermit/sdk/automanage/2022-05-04/automanage github.com/tombuildsstuff/kermit/sdk/batch/2022-01.15.0/batch github.com/tombuildsstuff/kermit/sdk/botservice/2021-05-01-preview/botservice github.com/tombuildsstuff/kermit/sdk/compute/2022-08-01/compute diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 901500582c34..619c2e509144 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -9,6 +9,7 @@ Application Insights ArcKubernetes Attestation Authorization +Automanage Automation Azure Stack HCI Base diff --git a/website/docs/r/automanage_configuration.html.markdown b/website/docs/r/automanage_configuration.html.markdown new file mode 100644 index 000000000000..1473202bc255 --- /dev/null +++ b/website/docs/r/automanage_configuration.html.markdown @@ -0,0 +1,125 @@ +--- +subcategory: "Automanage" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_automanage_configuration" +description: |- + Manages an Automanage Configuration. +--- + +# azurerm_automanage_configuration + +Manages an Automanage Configuration. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-automanage" + location = "West Europe" +} + +resource "azurerm_automanage_configuration" "example" { + name = "example-acmp" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + + antimalware { + exclusions { + extensions = "exe;dll" + paths = "C:\\Windows\\Temp;D:\\Temp" + processes = "svchost.exe;notepad.exe" + } + + real_time_protection_enabled = true + scheduled_scan_enabled = true + scheduled_scan_type = "Quick" + scheduled_scan_day = 1 + scheduled_scan_time_in_minutes = 1339 + } + + automation_account_enabled = true + boot_diagnostics_enabled = true + defender_for_cloud_enabled = true + guest_configuration_enabled = true + status_change_alert_enabled = true + + tags = { + "env" = "test" + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name which should be used for this Automanage Configuration. Changing this forces a new Automanage Configuration to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the Automanage Configuration should exist. Changing this forces a new Automanage Configuration to be created. + +* `location` - (Required) The Azure Region where the Automanage Configuration should exist. Changing this forces a new Automanage Configuration to be created. + +* `antimalware` - (Optional) A `antimalware` block as defined below. + +* `automation_account_enabled` - (Optional) Whether the automation account is enabled. Defaults to `false`. + +* `boot_diagnostics_enabled` - (Optional) Whether the boot diagnostics are enabled. Defaults to `false`. + +* `defender_for_cloud_enabled` - (Optional) Whether the defender for cloud is enabled. Defaults to `false`. + +* `guest_configuration_enabled` - (Optional) Whether the guest configuration is enabled. Defaults to `false`. + +* `status_change_alert_enabled` - (Optional) Whether the status change alert is enabled. Defaults to `false`. + +--- + +* `antimalware` supports the following: + +* `exclusions` - (Optional) A `exclusions` block as defined below. + +* `real_time_protection_enabled` - (Optional) Whether the real time protection is enabled. Defaults to `false`. + +* `scheduled_scan_enabled` - (Optional) Whether the scheduled scan is enabled. Defaults to `false`. + +* `scheduled_scan_type` - (Optional) The type of the scheduled scan. Possible values are `Quick` and `Full`. Defaults to `Quick`. + +* `scheduled_scan_day` - (Optional) The day of the scheduled scan. Possible values are `0` to `8` where `0` is daily, `1` to `7` are the days of the week and `8` is Disabled. Defaults to `8`. + +* `scheduled_scan_time_in_minutes` - (Optional) The time of the scheduled scan in minutes. Possible values are `0` to `1439` where `0` is 12:00 AM and `1439` is 11:59 PM. + +--- + +* `exclusions` supports the following: + +* `extensions` - (Optional) The extensions to exclude from the antimalware scan, separated by `;`. For example `.ext1;.ext2`. + +* `paths` - (Optional) The paths to exclude from the antimalware scan, separated by `;`. For example `C:\\Windows\\Temp;D:\\Temp`. + +* `processes` - (Optional) The processes to exclude from the antimalware scan, separated by `;`. For example `svchost.exe;notepad.exe`. + +* `tags` - (Optional) A mapping of tags which should be assigned to the Automanage Configuration. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Automanage Configuration. + +* `type` - The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Automanage Configuration. +* `read` - (Defaults to 5 minutes) Used when retrieving the Automanage Configuration. +* `update` - (Defaults to 30 minutes) Used when updating the Automanage Configuration. +* `delete` - (Defaults to 30 minutes) Used when deleting the Automanage Configuration. + +## Import + +Automanage Configuration can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_automanage_configuration.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Automanage/configurationProfiles/configurationProfile1 +```