diff --git a/azurerm/internal/clients/client.go b/azurerm/internal/clients/client.go index 1c88f9aeb06f..0d7e6c005896 100644 --- a/azurerm/internal/clients/client.go +++ b/azurerm/internal/clients/client.go @@ -41,6 +41,7 @@ import ( loganalytics "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/client" logic "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/logic/client" machinelearning "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/machinelearning/client" + maintenance "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/maintenance/client" managedapplication "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managedapplications/client" managementgroup "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managementgroup/client" maps "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/maps/client" @@ -118,6 +119,7 @@ type Client struct { LogAnalytics *loganalytics.Client Logic *logic.Client MachineLearning *machinelearning.Client + Maintenance *maintenance.Client ManagedApplication *managedapplication.Client ManagementGroups *managementgroup.Client Maps *maps.Client @@ -196,6 +198,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error client.LogAnalytics = loganalytics.NewClient(o) client.Logic = logic.NewClient(o) client.MachineLearning = machinelearning.NewClient(o) + client.Maintenance = maintenance.NewClient(o) client.ManagedApplication = managedapplication.NewClient(o) client.ManagementGroups = managementgroup.NewClient(o) client.Maps = maps.NewClient(o) diff --git a/azurerm/internal/provider/required_resource_providers.go b/azurerm/internal/provider/required_resource_providers.go index fa86fdaf3ad1..7db92125f4de 100644 --- a/azurerm/internal/provider/required_resource_providers.go +++ b/azurerm/internal/provider/required_resource_providers.go @@ -49,6 +49,7 @@ func RequiredResourceProviders() map[string]struct{} { "microsoft.insights": {}, "Microsoft.Logic": {}, "Microsoft.MachineLearningServices": {}, + "Microsoft.Maintenance": {}, "Microsoft.ManagedIdentity": {}, "Microsoft.Management": {}, "Microsoft.Maps": {}, diff --git a/azurerm/internal/provider/services.go b/azurerm/internal/provider/services.go index eb0e855b0f09..a98bfb872a98 100644 --- a/azurerm/internal/provider/services.go +++ b/azurerm/internal/provider/services.go @@ -37,6 +37,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/logic" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/machinelearning" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/maintenance" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managedapplications" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/managementgroup" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/maps" @@ -111,6 +112,7 @@ func SupportedServices() []common.ServiceRegistration { loganalytics.Registration{}, logic.Registration{}, machinelearning.Registration{}, + maintenance.Registration{}, managedapplications.Registration{}, managementgroup.Registration{}, maps.Registration{}, diff --git a/azurerm/internal/services/maintenance/client/client.go b/azurerm/internal/services/maintenance/client/client.go new file mode 100644 index 000000000000..5fb54aed666c --- /dev/null +++ b/azurerm/internal/services/maintenance/client/client.go @@ -0,0 +1,19 @@ +package client + +import ( + "github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" +) + +type Client struct { + ConfigurationsClient *maintenance.ConfigurationsClient +} + +func NewClient(o *common.ClientOptions) *Client { + configurationsClient := maintenance.NewConfigurationsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&configurationsClient.Client, o.ResourceManagerAuthorizer) + + return &Client{ + ConfigurationsClient: &configurationsClient, + } +} diff --git a/azurerm/internal/services/maintenance/data_source_maintenance_configuration.go b/azurerm/internal/services/maintenance/data_source_maintenance_configuration.go new file mode 100644 index 000000000000..75e6ad0b0a50 --- /dev/null +++ b/azurerm/internal/services/maintenance/data_source_maintenance_configuration.go @@ -0,0 +1,77 @@ +package maintenance + +import ( + "fmt" + "log" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func dataSourceMaintenanceConfiguration() *schema.Resource { + return &schema.Resource{ + Read: dataSourceArmMaintenanceConfigurationRead, + + Timeouts: &schema.ResourceTimeout{ + Read: schema.DefaultTimeout(5 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "resource_group_name": azure.SchemaResourceGroupNameForDataSource(), + + "location": azure.SchemaLocationForDataSource(), + + "scope": { + Type: schema.TypeString, + Computed: true, + }, + + "tags": tags.SchemaDataSource(), + }, + } +} + +func dataSourceArmMaintenanceConfigurationRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Maintenance.ConfigurationsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + resGroup := d.Get("resource_group_name").(string) + + resp, err := client.Get(ctx, resGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[INFO] Maintenance Configuration %q does not exist - removing from state", d.Id()) + d.SetId("") + return nil + } + return fmt.Errorf("failure retrieving MaintenanceConfiguration %q (Resource Group %q): %+v", name, resGroup, err) + } + + if id := resp.ID; id != nil { + d.SetId(*resp.ID) + } + + d.Set("name", name) + d.Set("resource_group_name", resGroup) + d.Set("location", location.NormalizeNilable(resp.Location)) + if props := resp.ConfigurationProperties; props != nil { + d.Set("scope", props.MaintenanceScope) + } + + return tags.FlattenAndSet(d, resp.Tags) +} diff --git a/azurerm/internal/services/maintenance/parse/maintenance_configuration.go b/azurerm/internal/services/maintenance/parse/maintenance_configuration.go new file mode 100644 index 000000000000..7630c7a7ee3e --- /dev/null +++ b/azurerm/internal/services/maintenance/parse/maintenance_configuration.go @@ -0,0 +1,39 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type MaintenanceConfigurationId struct { + ResourceGroup string + Name string +} + +func MaintenanceConfigurationID(input string) (*MaintenanceConfigurationId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse MaintenanceConfiguration ID %q: %+v", input, err) + } + + maintenanceConfiguration := MaintenanceConfigurationId{ + ResourceGroup: id.ResourceGroup, + } + + if name, err := id.PopSegment("maintenanceconfigurations"); err != nil { + if name, err = id.PopSegment("maintenanceConfigurations"); err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse maintenanceconfigurations/maintenanceConfigurations element %q: %+v", input, err) + } else { + maintenanceConfiguration.Name = name + } + } else { + maintenanceConfiguration.Name = name + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &maintenanceConfiguration, nil +} diff --git a/azurerm/internal/services/maintenance/parse/maintenance_configuration_test.go b/azurerm/internal/services/maintenance/parse/maintenance_configuration_test.go new file mode 100644 index 000000000000..f8c0fa04ce88 --- /dev/null +++ b/azurerm/internal/services/maintenance/parse/maintenance_configuration_test.go @@ -0,0 +1,74 @@ +package parse + +import ( + "testing" +) + +func TestMaintenanceConfigurationID(t *testing.T) { + testData := []struct { + Name string + Input string + Error bool + Expect *MaintenanceConfigurationId + }{ + { + Name: "Empty", + Input: "", + Error: true, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Error: true, + }, + { + Name: "Missing Maintenance Configuration Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/microsoft.maintenance/maintenanceconfigurations/", + Error: true, + }, + { + Name: "Maintenance Configuration ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/microsoft.maintenance/maintenanceconfigurations/mc1", + Error: false, + Expect: &MaintenanceConfigurationId{ + ResourceGroup: "resGroup1", + Name: "mc1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/microsoft.maintenance/MaintenanceConfigurations/mc1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q..", v.Name) + + actual, err := MaintenanceConfigurationID(v.Input) + if err != nil { + if v.Expect == nil { + continue + } + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.ResourceGroup != v.Expect.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expect.ResourceGroup, actual.ResourceGroup) + } + + if actual.Name != v.Expect.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + } + } +} diff --git a/azurerm/internal/services/maintenance/registration.go b/azurerm/internal/services/maintenance/registration.go new file mode 100644 index 000000000000..d461b1a485d8 --- /dev/null +++ b/azurerm/internal/services/maintenance/registration.go @@ -0,0 +1,29 @@ +package maintenance + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" +) + +type Registration struct{} + +func (r Registration) Name() string { + return "Maintenance" +} + +func (r Registration) WebsiteCategories() []string { + return []string{ + "Maintenance", + } +} + +func (r Registration) SupportedDataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "azurerm_maintenance_configuration": dataSourceMaintenanceConfiguration(), + } +} + +func (r Registration) SupportedResources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "azurerm_maintenance_configuration": resourceArmMaintenanceConfiguration(), + } +} diff --git a/azurerm/internal/services/maintenance/resource_arm_maintenance_configuration.go b/azurerm/internal/services/maintenance/resource_arm_maintenance_configuration.go new file mode 100644 index 000000000000..e5d2ae5ea096 --- /dev/null +++ b/azurerm/internal/services/maintenance/resource_arm_maintenance_configuration.go @@ -0,0 +1,176 @@ +package maintenance + +import ( + "fmt" + "log" + "time" + + "github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/maintenance/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/maintenance/validate" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" + azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmMaintenanceConfiguration() *schema.Resource { + return &schema.Resource{ + Create: resourceArmMaintenanceConfigurationCreateUpdate, + Read: resourceArmMaintenanceConfigurationRead, + Update: resourceArmMaintenanceConfigurationCreateUpdate, + Delete: resourceArmMaintenanceConfigurationDelete, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(30 * time.Minute), + Read: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(30 * time.Minute), + Delete: schema.DefaultTimeout(30 * time.Minute), + }, + + Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error { + _, err := parse.MaintenanceConfigurationID(id) + return err + }), + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "location": azure.SchemaLocation(), + + // There's a bug in the Azure API where this is returned in lower-case + // BUG: https://github.com/Azure/azure-rest-api-specs/issues/8653 + "resource_group_name": azure.SchemaResourceGroupNameDiffSuppress(), + + "scope": { + Type: schema.TypeString, + Optional: true, + Default: string(maintenance.ScopeAll), + ValidateFunc: validation.StringInSlice([]string{ + string(maintenance.ScopeAll), + string(maintenance.ScopeHost), + string(maintenance.ScopeInResource), + string(maintenance.ScopeResource), + }, false), + }, + + // There's a bug in the Azure API where the the key of tags is returned in lower-case + // BUG: https://github.com/Azure/azure-rest-api-specs/issues/9075 + // use custom tags defition here to prevent inputting upper case key + "tags": { + Type: schema.TypeMap, + Optional: true, + ValidateFunc: validate.TagsWithLowerCaseKey, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + } +} + +func resourceArmMaintenanceConfigurationCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Maintenance.ConfigurationsClient + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + resGroup := d.Get("resource_group_name").(string) + + if d.IsNewResource() { + existing, err := client.Get(ctx, resGroup, name) + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("failure checking for present of existing MaintenanceConfiguration %q (Resource Group %q): %+v", name, resGroup, err) + } + } + if existing.ID != nil && *existing.ID != "" { + return tf.ImportAsExistsError("azurerm_maintenance_configuration", *existing.ID) + } + } + + location := azure.NormalizeLocation(d.Get("location").(string)) + scope := d.Get("scope").(string) + + configuration := maintenance.Configuration{ + Name: utils.String(name), + Location: utils.String(location), + ConfigurationProperties: &maintenance.ConfigurationProperties{ + MaintenanceScope: maintenance.Scope(scope), + Namespace: utils.String("Microsoft.Maintenance"), + }, + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), + } + + if _, err := client.CreateOrUpdate(ctx, resGroup, name, configuration); err != nil { + return fmt.Errorf("failure creating/updating MaintenanceConfiguration %q (Resource Group %q): %+v", name, resGroup, err) + } + + resp, err := client.Get(ctx, resGroup, name) + if err != nil { + return fmt.Errorf("failure retrieving MaintenanceConfiguration %q (Resource Group %q): %+v", name, resGroup, err) + } + + if resp.ID == nil || *resp.ID == "" { + return fmt.Errorf("cannot read MaintenanceConfiguration %q (Resource Group %q) ID", name, resGroup) + } + + d.SetId(*resp.ID) + return resourceArmMaintenanceConfigurationRead(d, meta) +} + +func resourceArmMaintenanceConfigurationRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Maintenance.ConfigurationsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.MaintenanceConfigurationID(d.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[INFO] maintenance %q does not exist - removing from state", d.Id()) + d.SetId("") + return nil + } + return fmt.Errorf("failure retrieving MaintenanceConfiguration %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + + d.Set("name", resp.Name) + d.Set("resource_group_name", id.ResourceGroup) + d.Set("location", location.NormalizeNilable(resp.Location)) + if props := resp.ConfigurationProperties; props != nil { + d.Set("scope", props.MaintenanceScope) + } + return tags.FlattenAndSet(d, resp.Tags) +} + +func resourceArmMaintenanceConfigurationDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Maintenance.ConfigurationsClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.MaintenanceConfigurationID(d.Id()) + if err != nil { + return err + } + + if _, err := client.Delete(ctx, id.ResourceGroup, id.Name); err != nil { + return fmt.Errorf("failure deleting MaintenanceConfiguration %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + return nil +} diff --git a/azurerm/internal/services/maintenance/tests/data_source_maintenance_configuration_test.go b/azurerm/internal/services/maintenance/tests/data_source_maintenance_configuration_test.go new file mode 100644 index 000000000000..268f228a7d2b --- /dev/null +++ b/azurerm/internal/services/maintenance/tests/data_source_maintenance_configuration_test.go @@ -0,0 +1,41 @@ +package tests + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" +) + +func TestAccDataSourceAzureRMMaintenanceConfiguration_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_maintenance_configuration", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMMaintenanceConfigurationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceMaintenanceConfiguration_complete(data), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(data.ResourceName, "scope", "Host"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.env", "TesT"), + ), + }, + }, + }) +} + +func testAccDataSourceMaintenanceConfiguration_complete(data acceptance.TestData) string { + template := testAccAzureRMMaintenanceConfiguration_complete(data) + return fmt.Sprintf(` +%s + +data "azurerm_maintenance_configuration" "test" { + name = azurerm_maintenance_configuration.test.name + resource_group_name = azurerm_maintenance_configuration.test.resource_group_name +} +`, template) +} diff --git a/azurerm/internal/services/maintenance/tests/resource_arm_maintenance_configuration_test.go b/azurerm/internal/services/maintenance/tests/resource_arm_maintenance_configuration_test.go new file mode 100644 index 000000000000..c326560621ce --- /dev/null +++ b/azurerm/internal/services/maintenance/tests/resource_arm_maintenance_configuration_test.go @@ -0,0 +1,234 @@ +package tests + +import ( + "fmt" + "net/http" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/maintenance/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func TestAccAzureRMMaintenanceConfiguration_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_maintenance_configuration", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMMaintenanceConfigurationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMMaintenanceConfiguration_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMaintenanceConfigurationExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "scope", "All"), + ), + }, + data.ImportStep(), + }, + }) +} + +func TestAccAzureRMMaintenanceConfiguration_requiresImport(t *testing.T) { + if !features.ShouldResourcesBeImported() { + t.Skip("Skipping since resources aren't required to be imported") + return + } + data := acceptance.BuildTestData(t, "azurerm_maintenance_configuration", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMMaintenanceConfigurationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMMaintenanceConfiguration_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMaintenanceConfigurationExists(data.ResourceName), + ), + }, + data.RequiresImportErrorStep(testAccAzureRMMaintenanceConfiguration_requiresImport), + }, + }) +} + +func TestAccAzureRMMaintenanceConfiguration_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_maintenance_configuration", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMMaintenanceConfigurationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMMaintenanceConfiguration_complete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMaintenanceConfigurationExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "scope", "Host"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.env", "TesT"), + ), + }, + data.ImportStep(), + }, + }) +} + +func TestAccAzureRMMaintenanceConfiguration_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_maintenance_configuration", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMMaintenanceConfigurationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMMaintenanceConfiguration_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMaintenanceConfigurationExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "scope", "All"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "0"), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMMaintenanceConfiguration_complete(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMaintenanceConfigurationExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "scope", "Host"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.env", "TesT"), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMMaintenanceConfiguration_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMMaintenanceConfigurationExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "scope", "All"), + resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "0"), + ), + }, + data.ImportStep(), + }, + }) +} + +func testCheckAzureRMMaintenanceConfigurationDestroy(s *terraform.State) error { + conn := acceptance.AzureProvider.Meta().(*clients.Client).Maintenance.ConfigurationsClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_maintenance_configuration" { + continue + } + + id, err := parse.MaintenanceConfigurationID(rs.Primary.ID) + if err != nil { + return err + } + + resp, err := conn.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + if !utils.ResponseWasNotFound(resp.Response) { + return err + } + } + + return nil + } + + return nil +} + +func testCheckAzureRMMaintenanceConfigurationExists(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + conn := acceptance.AzureProvider.Meta().(*clients.Client).Maintenance.ConfigurationsClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Not found: %s", resourceName) + } + + id, err := parse.MaintenanceConfigurationID(rs.Primary.ID) + if err != nil { + return err + } + + resp, err := conn.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + return fmt.Errorf("Bad: Get on maintenanceConfigurationsClient: %+v", err) + } + + if resp.StatusCode == http.StatusNotFound { + return fmt.Errorf("Bad: Maintenance Configuration %q (resource group: %q) does not exist", id.Name, id.ResourceGroup) + } + + return nil + } +} + +func testAccAzureRMMaintenanceConfiguration_basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-maint-%d" + location = "%s" +} + +resource "azurerm_maintenance_configuration" "test" { + name = "acctest-MC%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + scope = "All" +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} + +func testAccAzureRMMaintenanceConfiguration_requiresImport(data acceptance.TestData) string { + template := testAccAzureRMMaintenanceConfiguration_basic(data) + return fmt.Sprintf(` +%s + +resource "azurerm_maintenance_configuration" "import" { + name = azurerm_maintenance_configuration.test.name + resource_group_name = azurerm_maintenance_configuration.test.resource_group_name + location = azurerm_maintenance_configuration.test.location + scope = azurerm_maintenance_configuration.test.scope +} +`, template) +} + +func testAccAzureRMMaintenanceConfiguration_complete(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-maint-%d" + location = "%s" +} + +resource "azurerm_maintenance_configuration" "test" { + name = "acctest-MC%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + scope = "Host" + + tags = { + env = "TesT" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} diff --git a/azurerm/internal/services/maintenance/validate/maintenance.go b/azurerm/internal/services/maintenance/validate/maintenance.go new file mode 100644 index 000000000000..b0abe6073d7c --- /dev/null +++ b/azurerm/internal/services/maintenance/validate/maintenance.go @@ -0,0 +1,22 @@ +package validate + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" +) + +func TagsWithLowerCaseKey(v interface{}, k string) (warnings []string, errors []error) { + warnings, errors = tags.Validate(v, k) + + tagsMap := v.(map[string]interface{}) + for key := range tagsMap { + for _, c := range key { + if c >= 'A' && c <= 'Z' { + errors = append(errors, fmt.Errorf("the key of %q can not contain upper case letter. The key %q has upper case letter %q", k, key, c)) + } + } + } + + return +} diff --git a/azurerm/internal/services/maintenance/validate/maintenance_test.go b/azurerm/internal/services/maintenance/validate/maintenance_test.go new file mode 100644 index 000000000000..3f398ad78814 --- /dev/null +++ b/azurerm/internal/services/maintenance/validate/maintenance_test.go @@ -0,0 +1,43 @@ +package validate + +import ( + "testing" +) + +func TestTagsWithLowerCaseKey(t *testing.T) { + testData := []struct { + input map[string]interface{} + expected bool + }{ + { + input: map[string]interface{}{}, + expected: true, + }, + { + // basic example + input: map[string]interface{}{ + "key1": "Value1", + "key2": "VALUE", + }, + expected: true, + }, + { + // contains upper case key + input: map[string]interface{}{ + "KEY": "value", + "key2": "VALUE", + }, + expected: false, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q..", v.input) + + _, errors := TagsWithLowerCaseKey(v.input, "tags") + actual := len(errors) == 0 + if v.expected != actual { + t.Fatalf("Expected %t but got %t", v.expected, actual) + } + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/applyupdates.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/applyupdates.go new file mode 100644 index 000000000000..251e5dbe5efe --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/applyupdates.go @@ -0,0 +1,374 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ApplyUpdatesClient is the azure Maintenance Management Client +type ApplyUpdatesClient struct { + BaseClient +} + +// NewApplyUpdatesClient creates an instance of the ApplyUpdatesClient client. +func NewApplyUpdatesClient(subscriptionID string) ApplyUpdatesClient { + return NewApplyUpdatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplyUpdatesClientWithBaseURI creates an instance of the ApplyUpdatesClient 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 NewApplyUpdatesClientWithBaseURI(baseURI string, subscriptionID string) ApplyUpdatesClient { + return ApplyUpdatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate apply maintenance updates to resource +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +func (client ApplyUpdatesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (result ApplyUpdate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplyUpdatesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, providerName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ApplyUpdatesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ApplyUpdatesClient) 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 ApplyUpdatesClient) CreateOrUpdateResponder(resp *http.Response) (result ApplyUpdate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateParent apply maintenance updates to resource with parent +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// resourceType - resource type +// resourceName - resource identifier +func (client ApplyUpdatesClient) CreateOrUpdateParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (result ApplyUpdate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplyUpdatesClient.CreateOrUpdateParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdateParentPreparer(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdateParent", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdateParent", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "CreateOrUpdateParent", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateParentPreparer prepares the CreateOrUpdateParent request. +func (client ApplyUpdatesClient) CreateOrUpdateParentPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateParentSender sends the CreateOrUpdateParent request. The method will close the +// http.Response Body if it receives an error. +func (client ApplyUpdatesClient) CreateOrUpdateParentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateParentResponder handles the response to the CreateOrUpdateParent request. The method always +// closes the http.Response Body. +func (client ApplyUpdatesClient) CreateOrUpdateParentResponder(resp *http.Response) (result ApplyUpdate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get track maintenance updates to resource +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +// applyUpdateName - applyUpdate Id +func (client ApplyUpdatesClient) Get(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string) (result ApplyUpdate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplyUpdatesClient.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, resourceGroupName, providerName, resourceType, resourceName, applyUpdateName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplyUpdatesClient) GetPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applyUpdateName": autorest.Encode("path", applyUpdateName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}", 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 ApplyUpdatesClient) 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 ApplyUpdatesClient) GetResponder(resp *http.Response) (result ApplyUpdate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetParent track maintenance updates to resource with parent +// Parameters: +// resourceGroupName - resource group name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +// applyUpdateName - applyUpdate Id +func (client ApplyUpdatesClient) GetParent(ctx context.Context, resourceGroupName string, resourceParentType string, resourceParentName string, providerName string, resourceType string, resourceName string, applyUpdateName string) (result ApplyUpdate, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplyUpdatesClient.GetParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetParentPreparer(ctx, resourceGroupName, resourceParentType, resourceParentName, providerName, resourceType, resourceName, applyUpdateName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "GetParent", nil, "Failure preparing request") + return + } + + resp, err := client.GetParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "GetParent", resp, "Failure sending request") + return + } + + result, err = client.GetParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ApplyUpdatesClient", "GetParent", resp, "Failure responding to request") + } + + return +} + +// GetParentPreparer prepares the GetParent request. +func (client ApplyUpdatesClient) GetParentPreparer(ctx context.Context, resourceGroupName string, resourceParentType string, resourceParentName string, providerName string, resourceType string, resourceName string, applyUpdateName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applyUpdateName": autorest.Encode("path", applyUpdateName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetParentSender sends the GetParent request. The method will close the +// http.Response Body if it receives an error. +func (client ApplyUpdatesClient) GetParentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetParentResponder handles the response to the GetParent request. The method always +// closes the http.Response Body. +func (client ApplyUpdatesClient) GetParentResponder(resp *http.Response) (result ApplyUpdate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/client.go new file mode 100644 index 000000000000..3fd605751946 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/client.go @@ -0,0 +1,52 @@ +// Package maintenance implements the Azure ARM Maintenance service API version 2018-06-01-preview. +// +// Azure Maintenance Management Client +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Maintenance + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Maintenance. +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/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurationassignments.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurationassignments.go new file mode 100644 index 000000000000..94895da09f20 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurationassignments.go @@ -0,0 +1,549 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ConfigurationAssignmentsClient is the azure Maintenance Management Client +type ConfigurationAssignmentsClient struct { + BaseClient +} + +// NewConfigurationAssignmentsClient creates an instance of the ConfigurationAssignmentsClient client. +func NewConfigurationAssignmentsClient(subscriptionID string) ConfigurationAssignmentsClient { + return NewConfigurationAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationAssignmentsClientWithBaseURI creates an instance of the ConfigurationAssignmentsClient 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 NewConfigurationAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationAssignmentsClient { + return ConfigurationAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate register configuration for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +// configurationAssignmentName - configuration assignment name +// configurationAssignment - the configurationAssignment +func (client ConfigurationAssignmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment) (result ConfigurationAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, providerName, resourceType, resourceName, configurationAssignmentName, configurationAssignment) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConfigurationAssignmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationAssignmentName": autorest.Encode("path", configurationAssignmentName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", pathParameters), + autorest.WithJSON(configurationAssignment), + 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 ConfigurationAssignmentsClient) 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 ConfigurationAssignmentsClient) CreateOrUpdateResponder(resp *http.Response) (result ConfigurationAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateParent register configuration for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// resourceType - resource type +// resourceName - resource identifier +// configurationAssignmentName - configuration assignment name +// configurationAssignment - the configurationAssignment +func (client ConfigurationAssignmentsClient) CreateOrUpdateParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment) (result ConfigurationAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.CreateOrUpdateParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdateParentPreparer(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, configurationAssignmentName, configurationAssignment) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdateParent", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdateParent", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "CreateOrUpdateParent", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateParentPreparer prepares the CreateOrUpdateParent request. +func (client ConfigurationAssignmentsClient) CreateOrUpdateParentPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationAssignmentName": autorest.Encode("path", configurationAssignmentName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", pathParameters), + autorest.WithJSON(configurationAssignment), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateParentSender sends the CreateOrUpdateParent request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationAssignmentsClient) CreateOrUpdateParentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateParentResponder handles the response to the CreateOrUpdateParent request. The method always +// closes the http.Response Body. +func (client ConfigurationAssignmentsClient) CreateOrUpdateParentResponder(resp *http.Response) (result ConfigurationAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete unregister configuration for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +// configurationAssignmentName - unique configuration assignment name +func (client ConfigurationAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string) (result ConfigurationAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, providerName, resourceType, resourceName, configurationAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConfigurationAssignmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationAssignmentName": autorest.Encode("path", configurationAssignmentName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", 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 ConfigurationAssignmentsClient) 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 ConfigurationAssignmentsClient) DeleteResponder(resp *http.Response) (result ConfigurationAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteParent unregister configuration for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// resourceType - resource type +// resourceName - resource identifier +// configurationAssignmentName - unique configuration assignment name +func (client ConfigurationAssignmentsClient) DeleteParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string) (result ConfigurationAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.DeleteParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteParentPreparer(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, configurationAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "DeleteParent", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "DeleteParent", resp, "Failure sending request") + return + } + + result, err = client.DeleteParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "DeleteParent", resp, "Failure responding to request") + } + + return +} + +// DeleteParentPreparer prepares the DeleteParent request. +func (client ConfigurationAssignmentsClient) DeleteParentPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationAssignmentName": autorest.Encode("path", configurationAssignmentName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteParentSender sends the DeleteParent request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationAssignmentsClient) DeleteParentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteParentResponder handles the response to the DeleteParent request. The method always +// closes the http.Response Body. +func (client ConfigurationAssignmentsClient) DeleteParentResponder(resp *http.Response) (result ConfigurationAssignment, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list configurationAssignments for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +func (client ConfigurationAssignmentsClient) List(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (result ListConfigurationAssignmentsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.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, resourceGroupName, providerName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ConfigurationAssignmentsClient) ListPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments", 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 ConfigurationAssignmentsClient) 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 ConfigurationAssignmentsClient) ListResponder(resp *http.Response) (result ListConfigurationAssignmentsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListParent list configurationAssignments for resource. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// resourceType - resource type +// resourceName - resource identifier +func (client ConfigurationAssignmentsClient) ListParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (result ListConfigurationAssignmentsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationAssignmentsClient.ListParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListParentPreparer(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "ListParent", nil, "Failure preparing request") + return + } + + resp, err := client.ListParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "ListParent", resp, "Failure sending request") + return + } + + result, err = client.ListParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationAssignmentsClient", "ListParent", resp, "Failure responding to request") + } + + return +} + +// ListParentPreparer prepares the ListParent request. +func (client ConfigurationAssignmentsClient) ListParentPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListParentSender sends the ListParent request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationAssignmentsClient) ListParentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListParentResponder handles the response to the ListParent request. The method always +// closes the http.Response Body. +func (client ConfigurationAssignmentsClient) ListParentResponder(resp *http.Response) (result ListConfigurationAssignmentsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurations.go new file mode 100644 index 000000000000..02f08d6069b3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/configurations.go @@ -0,0 +1,423 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ConfigurationsClient is the azure Maintenance Management Client +type ConfigurationsClient struct { + BaseClient +} + +// NewConfigurationsClient creates an instance of the ConfigurationsClient client. +func NewConfigurationsClient(subscriptionID string) ConfigurationsClient { + return NewConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationsClientWithBaseURI creates an instance of the ConfigurationsClient 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 NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient { + return ConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - resource Group Name +// resourceName - resource Identifier +// configuration - the configuration +func (client ConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration) (result Configuration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, configuration) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConfigurationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}", pathParameters), + autorest.WithJSON(configuration), + 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 ConfigurationsClient) 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 ConfigurationsClient) CreateOrUpdateResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete sends the delete request. +// Parameters: +// resourceGroupName - resource Group Name +// resourceName - resource Identifier +func (client ConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result Configuration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Delete") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConfigurationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}", 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 ConfigurationsClient) 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 ConfigurationsClient) DeleteResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - resource Group Name +// resourceName - resource Identifier +func (client ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result Configuration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.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, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}", 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 ConfigurationsClient) 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 ConfigurationsClient) GetResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +func (client ConfigurationsClient) List(ctx context.Context) (result ListMaintenanceConfigurationsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.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, "maintenance.ConfigurationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ConfigurationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations", 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 ConfigurationsClient) 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 ConfigurationsClient) ListResponder(resp *http.Response) (result ListMaintenanceConfigurationsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateMethod sends the update method request. +// Parameters: +// resourceGroupName - resource Group Name +// resourceName - resource Identifier +// configuration - the configuration +func (client ConfigurationsClient) UpdateMethod(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration) (result Configuration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.UpdateMethod") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateMethodPreparer(ctx, resourceGroupName, resourceName, configuration) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "UpdateMethod", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateMethodSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "UpdateMethod", resp, "Failure sending request") + return + } + + result, err = client.UpdateMethodResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.ConfigurationsClient", "UpdateMethod", resp, "Failure responding to request") + } + + return +} + +// UpdateMethodPreparer prepares the UpdateMethod request. +func (client ConfigurationsClient) UpdateMethodPreparer(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}", pathParameters), + autorest.WithJSON(configuration), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateMethodSender sends the UpdateMethod request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) UpdateMethodSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateMethodResponder handles the response to the UpdateMethod request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) UpdateMethodResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/models.go new file mode 100644 index 000000000000..34796e7b49c1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/models.go @@ -0,0 +1,581 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance" + +// ImpactType enumerates the values for impact type. +type ImpactType string + +const ( + // Freeze ... + Freeze ImpactType = "Freeze" + // None ... + None ImpactType = "None" + // Redeploy ... + Redeploy ImpactType = "Redeploy" + // Restart ... + Restart ImpactType = "Restart" +) + +// PossibleImpactTypeValues returns an array of possible values for the ImpactType const type. +func PossibleImpactTypeValues() []ImpactType { + return []ImpactType{Freeze, None, Redeploy, Restart} +} + +// Scope enumerates the values for scope. +type Scope string + +const ( + // ScopeAll ... + ScopeAll Scope = "All" + // ScopeHost ... + ScopeHost Scope = "Host" + // ScopeInResource ... + ScopeInResource Scope = "InResource" + // ScopeResource ... + ScopeResource Scope = "Resource" +) + +// PossibleScopeValues returns an array of possible values for the Scope const type. +func PossibleScopeValues() []Scope { + return []Scope{ScopeAll, ScopeHost, ScopeInResource, ScopeResource} +} + +// UpdateStatus enumerates the values for update status. +type UpdateStatus string + +const ( + // Completed ... + Completed UpdateStatus = "Completed" + // InProgress ... + InProgress UpdateStatus = "InProgress" + // Pending ... + Pending UpdateStatus = "Pending" + // RetryLater ... + RetryLater UpdateStatus = "RetryLater" + // RetryNow ... + RetryNow UpdateStatus = "RetryNow" +) + +// PossibleUpdateStatusValues returns an array of possible values for the UpdateStatus const type. +func PossibleUpdateStatusValues() []UpdateStatus { + return []UpdateStatus{Completed, InProgress, Pending, RetryLater, RetryNow} +} + +// ApplyUpdate apply Update request +type ApplyUpdate struct { + autorest.Response `json:"-"` + // ApplyUpdateProperties - Properties of the apply update + *ApplyUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified identifier of the resource + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type of the resource + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplyUpdate. +func (au ApplyUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if au.ApplyUpdateProperties != nil { + objectMap["properties"] = au.ApplyUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplyUpdate struct. +func (au *ApplyUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var applyUpdateProperties ApplyUpdateProperties + err = json.Unmarshal(*v, &applyUpdateProperties) + if err != nil { + return err + } + au.ApplyUpdateProperties = &applyUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + au.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + au.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + au.Type = &typeVar + } + } + } + + return nil +} + +// ApplyUpdateProperties properties for apply update +type ApplyUpdateProperties struct { + // Status - The status. Possible values include: 'Pending', 'InProgress', 'Completed', 'RetryNow', 'RetryLater' + Status UpdateStatus `json:"status,omitempty"` + // ResourceID - The resourceId + ResourceID *string `json:"resourceId,omitempty"` + // LastUpdateTime - Last Update time + LastUpdateTime *date.Time `json:"lastUpdateTime,omitempty"` +} + +// Configuration maintenance configuration record type +type Configuration struct { + autorest.Response `json:"-"` + // Location - Gets or sets location of the resource + Location *string `json:"location,omitempty"` + // Tags - Gets or sets tags of the resource + Tags map[string]*string `json:"tags"` + // ConfigurationProperties - Gets or sets properties of the resource + *ConfigurationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified identifier of the resource + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type of the resource + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Configuration. +func (c Configuration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.Location != nil { + objectMap["location"] = c.Location + } + if c.Tags != nil { + objectMap["tags"] = c.Tags + } + if c.ConfigurationProperties != nil { + objectMap["properties"] = c.ConfigurationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Configuration struct. +func (c *Configuration) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + c.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + c.Tags = tags + } + case "properties": + if v != nil { + var configurationProperties ConfigurationProperties + err = json.Unmarshal(*v, &configurationProperties) + if err != nil { + return err + } + c.ConfigurationProperties = &configurationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ConfigurationAssignment configuration Assignment +type ConfigurationAssignment struct { + autorest.Response `json:"-"` + // Location - Location of the resource + Location *string `json:"location,omitempty"` + // ConfigurationAssignmentProperties - Properties of the configuration assignment + *ConfigurationAssignmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified identifier of the resource + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type of the resource + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationAssignment. +func (ca ConfigurationAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ca.Location != nil { + objectMap["location"] = ca.Location + } + if ca.ConfigurationAssignmentProperties != nil { + objectMap["properties"] = ca.ConfigurationAssignmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConfigurationAssignment struct. +func (ca *ConfigurationAssignment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ca.Location = &location + } + case "properties": + if v != nil { + var configurationAssignmentProperties ConfigurationAssignmentProperties + err = json.Unmarshal(*v, &configurationAssignmentProperties) + if err != nil { + return err + } + ca.ConfigurationAssignmentProperties = &configurationAssignmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ca.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ca.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ca.Type = &typeVar + } + } + } + + return nil +} + +// ConfigurationAssignmentProperties properties for configuration assignment +type ConfigurationAssignmentProperties struct { + // MaintenanceConfigurationID - The maintenance configuration Id + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` + // ResourceID - The unique resourceId + ResourceID *string `json:"resourceId,omitempty"` +} + +// ConfigurationProperties properties for maintenance configuration +type ConfigurationProperties struct { + // Namespace - Gets or sets namespace of the resource + Namespace *string `json:"namespace,omitempty"` + // ExtensionProperties - Gets or sets extensionProperties of the maintenanceConfiguration + ExtensionProperties map[string]*string `json:"extensionProperties"` + // MaintenanceScope - Gets or sets maintenanceScope of the configuration. Possible values include: 'ScopeAll', 'ScopeHost', 'ScopeResource', 'ScopeInResource' + MaintenanceScope Scope `json:"maintenanceScope,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationProperties. +func (cp ConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.Namespace != nil { + objectMap["namespace"] = cp.Namespace + } + if cp.ExtensionProperties != nil { + objectMap["extensionProperties"] = cp.ExtensionProperties + } + if cp.MaintenanceScope != "" { + objectMap["maintenanceScope"] = cp.MaintenanceScope + } + return json.Marshal(objectMap) +} + +// Error an error response received from the Azure Maintenance service. +type Error struct { + // Error - Details of the error + Error *ErrorDetails `json:"error,omitempty"` +} + +// ErrorDetails an error response details received from the Azure Maintenance service. +type ErrorDetails struct { + // Code - Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. + Code *string `json:"code,omitempty"` + // Message - Human-readable representation of the error. + Message *string `json:"message,omitempty"` +} + +// ListConfigurationAssignmentsResult response for ConfigurationAssignments list +type ListConfigurationAssignmentsResult struct { + autorest.Response `json:"-"` + // Value - The list of configuration Assignments + Value *[]ConfigurationAssignment `json:"value,omitempty"` +} + +// ListMaintenanceConfigurationsResult response for MaintenanceConfigurations list +type ListMaintenanceConfigurationsResult struct { + autorest.Response `json:"-"` + // Value - The list of maintenance Configurations + Value *[]Configuration `json:"value,omitempty"` +} + +// ListUpdatesResult response for Updates list +type ListUpdatesResult struct { + autorest.Response `json:"-"` + // Value - The pending updates + Value *[]Update `json:"value,omitempty"` +} + +// Operation represents an operation returned by the GetOperations request +type Operation struct { + // Name - Name of the operation + Name *string `json:"name,omitempty"` + // Display - Display name of the operation + Display *OperationInfo `json:"display,omitempty"` + // Origin - Origin of the operation + Origin *string `json:"origin,omitempty"` + // Properties - Properties of the operation + Properties interface{} `json:"properties,omitempty"` +} + +// OperationInfo information about an operation +type OperationInfo struct { + // Provider - Name of the provider + Provider *string `json:"provider,omitempty"` + // Resource - Name of the resource type + Resource *string `json:"resource,omitempty"` + // Operation - Name of the operation + Operation *string `json:"operation,omitempty"` + // Description - Description of the operation + Description *string `json:"description,omitempty"` +} + +// OperationsListResult result of the List Operations operation +type OperationsListResult struct { + autorest.Response `json:"-"` + // Value - A collection of operations + Value *[]Operation `json:"value,omitempty"` +} + +// Resource definition of a Resource +type Resource struct { + // ID - READ-ONLY; Fully qualified identifier of the resource + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type of the resource + Type *string `json:"type,omitempty"` +} + +// Update maintenance update on a resource +type Update struct { + // MaintenanceScope - The impact area. Possible values include: 'ScopeAll', 'ScopeHost', 'ScopeResource', 'ScopeInResource' + MaintenanceScope Scope `json:"maintenanceScope,omitempty"` + // ImpactType - The impact type. Possible values include: 'None', 'Freeze', 'Restart', 'Redeploy' + ImpactType ImpactType `json:"impactType,omitempty"` + // Status - The status. Possible values include: 'Pending', 'InProgress', 'Completed', 'RetryNow', 'RetryLater' + Status UpdateStatus `json:"status,omitempty"` + // ImpactDurationInSec - Duration of impact in seconds + ImpactDurationInSec *int32 `json:"impactDurationInSec,omitempty"` + // NotBefore - Time when Azure will start force updates if not self-updated by customer before this time + NotBefore *date.Time `json:"notBefore,omitempty"` + // UpdateProperties - Properties of the apply update + *UpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for Update. +func (u Update) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if u.MaintenanceScope != "" { + objectMap["maintenanceScope"] = u.MaintenanceScope + } + if u.ImpactType != "" { + objectMap["impactType"] = u.ImpactType + } + if u.Status != "" { + objectMap["status"] = u.Status + } + if u.ImpactDurationInSec != nil { + objectMap["impactDurationInSec"] = u.ImpactDurationInSec + } + if u.NotBefore != nil { + objectMap["notBefore"] = u.NotBefore + } + if u.UpdateProperties != nil { + objectMap["properties"] = u.UpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Update struct. +func (u *Update) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "maintenanceScope": + if v != nil { + var maintenanceScope Scope + err = json.Unmarshal(*v, &maintenanceScope) + if err != nil { + return err + } + u.MaintenanceScope = maintenanceScope + } + case "impactType": + if v != nil { + var impactType ImpactType + err = json.Unmarshal(*v, &impactType) + if err != nil { + return err + } + u.ImpactType = impactType + } + case "status": + if v != nil { + var status UpdateStatus + err = json.Unmarshal(*v, &status) + if err != nil { + return err + } + u.Status = status + } + case "impactDurationInSec": + if v != nil { + var impactDurationInSec int32 + err = json.Unmarshal(*v, &impactDurationInSec) + if err != nil { + return err + } + u.ImpactDurationInSec = &impactDurationInSec + } + case "notBefore": + if v != nil { + var notBefore date.Time + err = json.Unmarshal(*v, ¬Before) + if err != nil { + return err + } + u.NotBefore = ¬Before + } + case "properties": + if v != nil { + var updateProperties UpdateProperties + err = json.Unmarshal(*v, &updateProperties) + if err != nil { + return err + } + u.UpdateProperties = &updateProperties + } + } + } + + return nil +} + +// UpdateProperties properties for update +type UpdateProperties struct { + // ResourceID - The resourceId + ResourceID *string `json:"resourceId,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/operations.go new file mode 100644 index 000000000000..7f997f6c392d --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/operations.go @@ -0,0 +1,109 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the azure Maintenance Management Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list the available operations supported by the Microsoft.Maintenance resource provider +func (client OperationsClient) List(ctx context.Context) (result OperationsListResult, 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, "maintenance.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, "maintenance.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Maintenance/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 OperationsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/updates.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/updates.go new file mode 100644 index 000000000000..6618f942b3f8 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/updates.go @@ -0,0 +1,206 @@ +package maintenance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// UpdatesClient is the azure Maintenance Management Client +type UpdatesClient struct { + BaseClient +} + +// NewUpdatesClient creates an instance of the UpdatesClient client. +func NewUpdatesClient(subscriptionID string) UpdatesClient { + return NewUpdatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUpdatesClientWithBaseURI creates an instance of the UpdatesClient 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 NewUpdatesClientWithBaseURI(baseURI string, subscriptionID string) UpdatesClient { + return UpdatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get updates to resources. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceType - resource type +// resourceName - resource identifier +func (client UpdatesClient) List(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (result ListUpdatesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UpdatesClient.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, resourceGroupName, providerName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client UpdatesClient) ListPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates", 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 UpdatesClient) 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 UpdatesClient) ListResponder(resp *http.Response) (result ListUpdatesResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListParent get updates to resources. +// Parameters: +// resourceGroupName - resource group name +// providerName - resource provider name +// resourceParentType - resource parent type +// resourceParentName - resource parent identifier +// resourceType - resource type +// resourceName - resource identifier +func (client UpdatesClient) ListParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (result ListUpdatesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UpdatesClient.ListParent") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListParentPreparer(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "ListParent", nil, "Failure preparing request") + return + } + + resp, err := client.ListParentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "ListParent", resp, "Failure sending request") + return + } + + result, err = client.ListParentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "maintenance.UpdatesClient", "ListParent", resp, "Failure responding to request") + } + + return +} + +// ListParentPreparer prepares the ListParent request. +func (client UpdatesClient) ListParentPreparer(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceParentName": autorest.Encode("path", resourceParentName), + "resourceParentType": autorest.Encode("path", resourceParentType), + "resourceType": autorest.Encode("path", resourceType), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListParentSender sends the ListParent request. The method will close the +// http.Response Body if it receives an error. +func (client UpdatesClient) ListParentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListParentResponder handles the response to the ListParent request. The method always +// closes the http.Response Body. +func (client UpdatesClient) ListParentResponder(resp *http.Response) (result ListUpdatesResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/version.go new file mode 100644 index 000000000000..dd7474e61c38 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance/version.go @@ -0,0 +1,30 @@ +package maintenance + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " maintenance/2018-06-01-preview" +} + +// 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 c54d03cc3beb..842df04416c9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -59,6 +59,7 @@ github.com/Azure/azure-sdk-for-go/services/preview/customproviders/mgmt/2018-09- github.com/Azure/azure-sdk-for-go/services/preview/eventgrid/mgmt/2018-09-15-preview/eventgrid github.com/Azure/azure-sdk-for-go/services/preview/hdinsight/mgmt/2018-06-01-preview/hdinsight github.com/Azure/azure-sdk-for-go/services/preview/iothub/mgmt/2018-12-01-preview/devices +github.com/Azure/azure-sdk-for-go/services/preview/maintenance/mgmt/2018-06-01-preview/maintenance github.com/Azure/azure-sdk-for-go/services/preview/mixedreality/mgmt/2019-02-28/mixedreality github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insights github.com/Azure/azure-sdk-for-go/services/preview/msi/mgmt/2015-08-31-preview/msi diff --git a/website/allowed-subcategories b/website/allowed-subcategories index d1c2c34478fa..f02f9b77c3f8 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -34,6 +34,7 @@ Load Balancer Log Analytics Logic App Machine Learning +Maintenance Managed Applications Management Maps diff --git a/website/azurerm.erb b/website/azurerm.erb index 82495facfd3a..832012888d78 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -306,6 +306,10 @@ azurerm_machine_learning_workspace +
  • + azurerm_maintenance_configuration +
  • +
  • azurerm_managed_application_definition
  • @@ -1673,6 +1677,15 @@ + + +
  • + Maintenance Resources +
  • diff --git a/website/docs/d/maintenance_configuration.html.markdown b/website/docs/d/maintenance_configuration.html.markdown new file mode 100644 index 000000000000..0d633f247cc4 --- /dev/null +++ b/website/docs/d/maintenance_configuration.html.markdown @@ -0,0 +1,44 @@ +--- +subcategory: "Maintenance" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_maintenance_configuration" +description: |- + Get information about an existing Maintenance Configuration. +--- + +# Data Source: azurerm_maintenance_configuration + +Use this data source to access information about an existing Maintenance Configuration. + +## Example Usage + +```hcl +data "azurerm_maintenance_configuration" "existing" { + name = "example-mc" + resource_group_name = "example-resources" +} + +output "id" { + value = azurerm_maintenance_configuration.existing.id +} +``` + +## Argument Reference + +* `name` - Specifies the name of the Maintenance Configuration. + +* `resource_group_name` - Specifies the name of the Resource Group where this Maintenance Configuration exists. + +## Attributes Reference + +* `location` - The Azure location where the resource exists. + +* `scope` - The scope of the Maintenance Configuration. + +* `tags` - A mapping of tags assigned to the resource. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `read` - (Defaults to 5 minutes) Used when retrieving the Maintenance Configuration. diff --git a/website/docs/r/maintenance_configuration.html.markdown b/website/docs/r/maintenance_configuration.html.markdown new file mode 100644 index 000000000000..e495e2e21ed6 --- /dev/null +++ b/website/docs/r/maintenance_configuration.html.markdown @@ -0,0 +1,74 @@ +--- +subcategory: "Maintenance" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_maintenance_configuration" +description: |- + Manages a Maintenance Configuration. +--- + +# azurerm_maintenance_configuration + +Manages a maintenance configuration. + +## Example Usage + +```hcl +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_maintenance_configuration" "example" { + name = "example-mc" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + scope = "All" + + tags = { + Env = "prod" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Maintenance Configuration. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the Maintenance Configuration should exist. Changing this forces a new resource to be created. + +* `location` - (Required) Specified the supported Azure location where the resource exists. Changing this forces a new resource to be created. + +* `scope` - (Optional) The scope of the Maintenance Configuration. Possible values are `All`, `Host`, `Resource` or `InResource`. Default to `All`. + +* `tags` - (Optional) A mapping of tags to assign to the resource. The key could not contain upper case letter. + +~> **NOTE** Because of restriction by the Maintenance backend service, the key in `tags` will be converted to lower case. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the Maintenance Configuration. + +## 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 Maintenance Configuration. +* `update` - (Defaults to 30 minutes) Used when updating the Maintenance Configuration. +* `read` - (Defaults to 5 minutes) Used when retrieving the Maintenance Configuration. +* `delete` - (Defaults to 30 minutes) Used when deleting the Maintenance Configuration. + +## Import + +Maintenance Configuration can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_maintenance_configuration.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.maintenance/maintenanceconfigurations/example-mc +```