From a0d801e1aebf9833ae7b10161088f87d9780043d Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 6 Apr 2023 17:08:35 -0700 Subject: [PATCH 1/5] Moving more resources to go-azure-sdk --- ...ckup_container_storage_account_resource.go | 88 ++-- ...container_storage_account_resource_test.go | 8 +- .../backup_policy_file_share_data_source.go | 22 +- .../backup_policy_file_share_resource.go | 299 ++++++------ .../backup_policy_file_share_resource_test.go | 8 +- .../backup_policy_vm_data_source.go | 26 +- .../backup_policy_vm_resource.go | 412 ++++++++--------- .../backup_policy_vm_resource_test.go | 8 +- .../backup_policy_vm_workload_resource.go | 346 +++++++------- ...backup_policy_vm_workload_resource_test.go | 8 +- .../backup_protected_file_share_resource.go | 149 +++--- ...ckup_protected_file_share_resource_test.go | 8 +- .../backup_protected_vm_resource.go | 152 ++++--- .../backup_protected_vm_resource_test.go | 8 +- .../recoveryservices/client/client.go | 25 +- .../backupprotectableitems/README.md | 37 ++ .../backupprotectableitems/client.go | 18 + .../backupprotectableitems/constants.go | 105 +++++ .../backupprotectableitems/id_vault.go | 127 ++++++ .../method_list_autorest.go | 215 +++++++++ .../model_azurefileshareprotectableitem.go | 47 ++ ...zureiaasclassiccomputevmprotectableitem.go | 47 ++ ...model_azureiaascomputevmprotectableitem.go | 47 ++ .../model_azurevmworkloadprotectableitem.go | 52 +++ ...revmworkloadsapasesystemprotectableitem.go | 52 +++ ...mworkloadsaphanadatabaseprotectableitem.go | 52 +++ ...evmworkloadsaphanasystemprotectableitem.go | 52 +++ ...loadsqlavailabilitygroupprotectableitem.go | 52 +++ ...urevmworkloadsqldatabaseprotectableitem.go | 52 +++ ...urevmworkloadsqlinstanceprotectableitem.go | 52 +++ .../model_iaasvmprotectableitem.go | 47 ++ .../model_prebackupvalidation.go | 10 + .../model_workloadprotectableitem.go | 128 ++++++ .../model_workloadprotectableitemresource.go | 50 +++ .../backupprotectableitems/predicates.go | 37 ++ .../backupprotectableitems/version.go | 12 + .../2021-12-01/backupprotecteditems/README.md | 37 ++ .../2021-12-01/backupprotecteditems/client.go | 18 + .../backupprotecteditems/constants.go | 378 ++++++++++++++++ .../backupprotecteditems/id_vault.go | 127 ++++++ .../method_list_autorest.go | 215 +++++++++ .../model_azurefileshareprotecteditem.go | 90 ++++ ...azurefileshareprotecteditemextendedinfo.go | 42 ++ ..._azureiaasclassiccomputevmprotecteditem.go | 95 ++++ .../model_azureiaascomputevmprotecteditem.go | 95 ++++ .../model_azureiaasvmprotecteditem.go | 95 ++++ ...el_azureiaasvmprotecteditemextendedinfo.go | 67 +++ .../model_azuresqlprotecteditem.go | 86 ++++ ...model_azuresqlprotecteditemextendedinfo.go | 28 ++ .../model_azurevmworkloadprotecteditem.go | 96 ++++ ...zurevmworkloadprotecteditemextendedinfo.go | 68 +++ ...revmworkloadsapasedatabaseprotecteditem.go | 96 ++++ ...evmworkloadsaphanadatabaseprotecteditem.go | 96 ++++ ...azurevmworkloadsqldatabaseprotecteditem.go | 96 ++++ .../model_diskexclusionproperties.go | 9 + .../model_dpmprotecteditem.go | 87 ++++ .../model_dpmprotecteditemextendedinfo.go | 75 ++++ .../backupprotecteditems/model_errordetail.go | 10 + .../model_extendedproperties.go | 9 + .../model_genericprotecteditem.go | 89 ++++ .../model_kpiresourcehealthdetails.go | 9 + .../model_mabfilefolderprotecteditem.go | 90 ++++ ..._mabfilefolderprotecteditemextendedinfo.go | 40 ++ .../model_protecteditem.go | 136 ++++++ .../model_protecteditemresource.go | 50 +++ .../model_resourcehealthdetails.go | 11 + .../backupprotecteditems/predicates.go | 37 ++ .../backupprotecteditems/version.go | 12 + .../2021-12-01/protecteditems/README.md | 73 +++ .../2021-12-01/protecteditems/client.go | 18 + .../2021-12-01/protecteditems/constants.go | 378 ++++++++++++++++ .../protecteditems/id_protecteditem.go | 166 +++++++ .../method_createorupdate_autorest.go | 69 +++ .../protecteditems/method_delete_autorest.go | 66 +++ .../protecteditems/method_get_autorest.go | 97 ++++ .../model_azurefileshareprotecteditem.go | 90 ++++ ...azurefileshareprotecteditemextendedinfo.go | 42 ++ ..._azureiaasclassiccomputevmprotecteditem.go | 95 ++++ .../model_azureiaascomputevmprotecteditem.go | 95 ++++ .../model_azureiaasvmprotecteditem.go | 95 ++++ ...el_azureiaasvmprotecteditemextendedinfo.go | 67 +++ .../model_azuresqlprotecteditem.go | 86 ++++ ...model_azuresqlprotecteditemextendedinfo.go | 28 ++ .../model_azurevmworkloadprotecteditem.go | 96 ++++ ...zurevmworkloadprotecteditemextendedinfo.go | 68 +++ ...revmworkloadsapasedatabaseprotecteditem.go | 96 ++++ ...evmworkloadsaphanadatabaseprotecteditem.go | 96 ++++ ...azurevmworkloadsqldatabaseprotecteditem.go | 96 ++++ .../model_diskexclusionproperties.go | 9 + .../protecteditems/model_dpmprotecteditem.go | 87 ++++ .../model_dpmprotecteditemextendedinfo.go | 75 ++++ .../protecteditems/model_errordetail.go | 10 + .../model_extendedproperties.go | 9 + .../model_genericprotecteditem.go | 89 ++++ .../model_kpiresourcehealthdetails.go | 9 + .../model_mabfilefolderprotecteditem.go | 90 ++++ ..._mabfilefolderprotecteditemextendedinfo.go | 40 ++ .../protecteditems/model_protecteditem.go | 136 ++++++ .../model_protecteditemresource.go | 50 +++ .../model_resourcehealthdetails.go | 11 + .../2021-12-01/protecteditems/version.go | 12 + .../2021-12-01/protectioncontainers/README.md | 105 +++++ .../2021-12-01/protectioncontainers/client.go | 18 + .../protectioncontainers/constants.go | 324 +++++++++++++ .../protectioncontainers/id_backupfabric.go | 140 ++++++ .../id_protectioncontainer.go | 153 +++++++ .../method_get_autorest.go | 68 +++ .../method_inquire_autorest.go | 96 ++++ .../method_refresh_autorest.go | 96 ++++ .../method_register_autorest.go | 69 +++ .../method_unregister_autorest.go | 66 +++ .../model_azurebackupservercontainer.go | 53 +++ ...odel_azureiaasclassiccomputevmcontainer.go | 48 ++ .../model_azureiaascomputevmcontainer.go | 48 ++ ...lagworkloadcontainerprotectioncontainer.go | 50 +++ .../model_azuresqlcontainer.go | 45 ++ .../model_azurestoragecontainer.go | 50 +++ ..._azurevmappcontainerprotectioncontainer.go | 50 +++ .../model_azureworkloadcontainer.go | 50 +++ ...odel_azureworkloadcontainerextendedinfo.go | 10 + .../model_containeridentityinfo.go | 11 + .../model_distributednodesinfo.go | 10 + .../model_dpmcontainer.go | 53 +++ .../model_dpmcontainerextendedinfo.go | 26 ++ .../protectioncontainers/model_errordetail.go | 10 + .../model_genericcontainer.go | 47 ++ .../model_genericcontainerextendedinfo.go | 10 + .../model_iaasvmcontainer.go | 48 ++ .../protectioncontainers/model_inquiryinfo.go | 10 + .../model_inquiryvalidation.go | 10 + .../model_mabcontainer.go | 52 +++ .../model_mabcontainerextendedinfo.go | 30 ++ .../model_mabcontainerhealthdetails.go | 11 + .../model_protectioncontainer.go | 136 ++++++ .../model_protectioncontainerresource.go | 50 +++ .../model_workloadinquirydetails.go | 10 + .../protectioncontainers/version.go | 12 + .../2021-12-01/protectionpolicies/README.md | 69 +++ .../2021-12-01/protectionpolicies/client.go | 18 + .../protectionpolicies/constants.go | 424 ++++++++++++++++++ .../protectionpolicies/id_backuppolicy.go | 140 ++++++ .../method_createorupdate_autorest.go | 69 +++ .../method_delete_autorest.go | 78 ++++ .../protectionpolicies/method_get_autorest.go | 68 +++ .../model_azurefileshareprotectionpolicy.go | 83 ++++ .../model_azureiaasvmprotectionpolicy.go | 89 ++++ .../model_azuresqlprotectionpolicy.go | 70 +++ .../model_azurevmworkloadprotectionpolicy.go | 46 ++ .../model_dailyretentionformat.go | 8 + .../model_dailyretentionschedule.go | 9 + .../protectionpolicies/model_dailyschedule.go | 8 + .../protectionpolicies/model_day.go | 9 + .../model_genericprotectionpolicy.go | 45 ++ .../model_hourlyschedule.go | 28 ++ .../model_instantrpadditionaldetails.go | 9 + .../model_logschedulepolicy.go | 41 ++ .../model_longtermretentionpolicy.go | 44 ++ .../model_longtermschedulepolicy.go | 40 ++ .../model_mabprotectionpolicy.go | 79 ++++ .../model_monthlyretentionschedule.go | 12 + .../model_protectionpolicy.go | 88 ++++ .../model_protectionpolicyresource.go | 50 +++ .../model_retentionduration.go | 9 + .../model_retentionpolicy.go | 56 +++ .../model_schedulepolicy.go | 72 +++ .../protectionpolicies/model_settings.go | 10 + .../model_simpleretentionpolicy.go | 41 ++ .../model_simpleschedulepolicy.go | 45 ++ .../model_simpleschedulepolicyv2.go | 44 ++ .../model_subprotectionpolicy.go | 51 +++ .../protectionpolicies/model_tieringpolicy.go | 10 + .../model_weeklyretentionformat.go | 9 + .../model_weeklyretentionschedule.go | 10 + .../model_weeklyschedule.go | 9 + .../model_yearlyretentionschedule.go | 13 + .../2021-12-01/protectionpolicies/version.go | 12 + vendor/modules.txt | 5 + 177 files changed, 11185 insertions(+), 801 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/id_vault.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/method_list_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurefileshareprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_iaasvmprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_prebackupvalidation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_workloadprotectableitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_workloadprotectableitemresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/id_vault.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/method_list_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurefileshareprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasvmprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azuresqlprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_diskexclusionproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_dpmprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_errordetail.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_extendedproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_genericprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_kpiresourcehealthdetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_mabfilefolderprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_protecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_protecteditemresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_resourcehealthdetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/id_protecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_createorupdate_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_delete_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_get_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurefileshareprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaascomputevmprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasvmprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azuresqlprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_diskexclusionproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_dpmprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_dpmprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_errordetail.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_extendedproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_genericprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_kpiresourcehealthdetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_mabfilefolderprotecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_protecteditem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_protecteditemresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_resourcehealthdetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/id_backupfabric.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/id_protectioncontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_get_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_inquire_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_refresh_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_register_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_unregister_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurebackupservercontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureiaascomputevmcontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azuresqlcontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurestoragecontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureworkloadcontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_containeridentityinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_distributednodesinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_dpmcontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_dpmcontainerextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_errordetail.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_genericcontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_genericcontainerextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_iaasvmcontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_inquiryinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_inquiryvalidation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainerextendedinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainerhealthdetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_protectioncontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_protectioncontainerresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_workloadinquirydetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/id_backuppolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_createorupdate_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_delete_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_get_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azurefileshareprotectionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azuresqlprotectionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyretentionformat.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyretentionschedule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyschedule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_day.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_genericprotectionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_hourlyschedule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_instantrpadditionaldetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_logschedulepolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_longtermretentionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_longtermschedulepolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_mabprotectionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_monthlyretentionschedule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_protectionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_protectionpolicyresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_retentionduration.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_retentionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_schedulepolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_settings.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleretentionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleschedulepolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleschedulepolicyv2.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_subprotectionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_tieringpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyretentionformat.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyretentionschedule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyschedule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_yearlyretentionschedule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/version.go diff --git a/internal/services/recoveryservices/backup_container_storage_account_resource.go b/internal/services/recoveryservices/backup_container_storage_account_resource.go index d8231357f3cc..6323fc03b11e 100644 --- a/internal/services/recoveryservices/backup_container_storage_account_resource.go +++ b/internal/services/recoveryservices/backup_container_storage_account_resource.go @@ -7,16 +7,17 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/validate" storageParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceBackupProtectionContainerStorageAccount() *pluginsdk.Resource { @@ -26,7 +27,7 @@ func resourceBackupProtectionContainerStorageAccount() *pluginsdk.Resource { Update: nil, Delete: resourceBackupProtectionContainerStorageAccountDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.ProtectionContainerID(id) + _, err := protectioncontainers.ParseProtectionContainerID(id) return err }), @@ -59,13 +60,11 @@ func resourceBackupProtectionContainerStorageAccount() *pluginsdk.Resource { func resourceBackupProtectionContainerStorageAccountCreate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).RecoveryServices.BackupProtectionContainersClient opStatusClient := meta.(*clients.Client).RecoveryServices.BackupOperationStatusesClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - resGroup := d.Get("resource_group_name").(string) - vaultName := d.Get("recovery_vault_name").(string) storageAccountID := d.Get("storage_account_id").(string) - parsedStorageAccountID, err := storageParse.StorageAccountID(storageAccountID) if err != nil { return fmt.Errorf("[ERROR] Unable to parse storage_account_id '%s': %+v", storageAccountID, err) @@ -73,36 +72,36 @@ func resourceBackupProtectionContainerStorageAccountCreate(d *pluginsdk.Resource containerName := fmt.Sprintf("StorageContainer;storage;%s;%s", parsedStorageAccountID.ResourceGroup, parsedStorageAccountID.Name) + id := protectioncontainers.NewProtectionContainerID(subscriptionId, d.Get("resource_group_name").(string), d.Get("recovery_vault_name").(string), "Azure", containerName) if d.IsNewResource() { - existing, err := client.Get(ctx, vaultName, resGroup, "Azure", containerName) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing recovery services protection container %s (Vault %s): %+v", containerName, vaultName, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if existing.ID != nil && *existing.ID != "" { - return tf.ImportAsExistsError("azurerm_backup_protection_container_storage", handleAzureSdkForGoBug2824(*existing.ID)) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_backup_protection_container_storage", id.ID()) } } - parameters := backup.ProtectionContainerResource{ - Properties: &backup.AzureStorageContainer{ - SourceResourceID: &storageAccountID, + parameters := protectioncontainers.ProtectionContainerResource{ + Properties: &protectioncontainers.AzureStorageContainer{ + SourceResourceId: &storageAccountID, FriendlyName: &parsedStorageAccountID.Name, - BackupManagementType: backup.ManagementTypeAzureStorage, - ContainerType: backup.ContainerTypeBasicProtectionContainerContainerTypeStorageContainer, + BackupManagementType: pointer.To(protectioncontainers.BackupManagementTypeAzureStorage), }, } - resp, err := client.Register(ctx, vaultName, resGroup, "Azure", containerName, parameters) + resp, err := client.Register(ctx, id, parameters) if err != nil { - return fmt.Errorf("registering backup protection container %s (Vault %s): %+v", containerName, vaultName, err) + return fmt.Errorf("registering %s: %+v", id, err) } - locationURL, err := resp.Response.Location() // Operation ID found in the Location header + locationURL, err := resp.HttpResponse.Location() // Operation ID found in the Location header if locationURL == nil || err != nil { - return fmt.Errorf("Unable to determine operation URL for protection container registration status for %s. (Vault %s): Location header missing or empty", containerName, vaultName) + return fmt.Errorf("unable to determine operation URL for %s: Location header missing or empty", id) } opResourceID := handleAzureSdkForGoBug2824(locationURL.Path) @@ -113,66 +112,63 @@ func resourceBackupProtectionContainerStorageAccountCreate(d *pluginsdk.Resource } operationID := parsedLocation.Path["operationResults"] - if err = resourceBackupProtectionContainerStorageAccountWaitForOperation(ctx, opStatusClient, vaultName, resGroup, operationID, d); err != nil { + if err = resourceBackupProtectionContainerStorageAccountWaitForOperation(ctx, opStatusClient, id.VaultName, id.ResourceGroupName, operationID, d); err != nil { return err } - resp, err = client.Get(ctx, vaultName, resGroup, "Azure", containerName) - if err != nil { - return fmt.Errorf("retrieving site recovery protection container %s (Vault %s): %+v", containerName, vaultName, err) - } - - d.SetId(handleAzureSdkForGoBug2824(*resp.ID)) + d.SetId(handleAzureSdkForGoBug2824(id.ID())) return resourceBackupProtectionContainerStorageAccountRead(d, meta) } func resourceBackupProtectionContainerStorageAccountRead(d *pluginsdk.ResourceData, meta interface{}) error { - id, err := parse.ProtectionContainerID(d.Id()) - if err != nil { - return err - } - client := meta.(*clients.Client).RecoveryServices.BackupProtectionContainersClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - resp, err := client.Get(ctx, id.VaultName, id.ResourceGroup, id.BackupFabricName, id.Name) + id, err := protectioncontainers.ParseProtectionContainerID(d.Id()) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + return err + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("making Read request on backup protection container %s : %+v", id.String(), err) } - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("recovery_vault_name", id.VaultName) - if properties, ok := resp.Properties.AsAzureStorageContainer(); ok && properties != nil { - d.Set("storage_account_id", properties.SourceResourceID) + if model := resp.Model; model != nil { + if properties, ok := model.Properties.(protectioncontainers.AzureStorageContainer); ok { + d.Set("storage_account_id", properties.SourceResourceId) + } } return nil } func resourceBackupProtectionContainerStorageAccountDelete(d *pluginsdk.ResourceData, meta interface{}) error { - id, err := parse.ProtectionContainerID(d.Id()) - if err != nil { - return err - } - client := meta.(*clients.Client).RecoveryServices.BackupProtectionContainersClient opClient := meta.(*clients.Client).RecoveryServices.BackupOperationStatusesClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - resp, err := client.Unregister(ctx, id.VaultName, id.ResourceGroup, id.BackupFabricName, id.Name) + id, err := protectioncontainers.ParseProtectionContainerID(d.Id()) + if err != nil { + return err + } + + resp, err := client.Unregister(ctx, *id) if err != nil { - return fmt.Errorf("deregistering backup protection container %s (Vault %s): %+v", id.Name, id.VaultName, err) + return fmt.Errorf("deregistering %s: %+v", id, err) } - locationURL, err := resp.Response.Location() + locationURL, err := resp.HttpResponse.Location() if err != nil || locationURL == nil { return fmt.Errorf("unregistering backup protection container %s : Location header missing or empty", id.String()) } @@ -185,7 +181,7 @@ func resourceBackupProtectionContainerStorageAccountDelete(d *pluginsdk.Resource } operationID := parsedLocation.Path["backupOperationResults"] - if err = resourceBackupProtectionContainerStorageAccountWaitForOperation(ctx, opClient, id.VaultName, id.ResourceGroup, operationID, d); err != nil { + if err = resourceBackupProtectionContainerStorageAccountWaitForOperation(ctx, opClient, id.VaultName, id.ResourceGroupName, operationID, d); err != nil { return err } diff --git a/internal/services/recoveryservices/backup_container_storage_account_resource_test.go b/internal/services/recoveryservices/backup_container_storage_account_resource_test.go index bd13439b2c10..0f1f69a36826 100644 --- a/internal/services/recoveryservices/backup_container_storage_account_resource_test.go +++ b/internal/services/recoveryservices/backup_container_storage_account_resource_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -31,16 +31,16 @@ func TestAccBackupProtectionContainerStorageAccount_basic(t *testing.T) { } func (t BackupProtectionContainerStorageAccountResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.ProtectionContainerID(state.ID) + id, err := protectioncontainers.ParseProtectionContainerID(state.ID) if err != nil { return nil, err } - resp, err := clients.RecoveryServices.BackupProtectionContainersClient.Get(ctx, id.VaultName, id.ResourceGroup, id.BackupFabricName, id.Name) + resp, err := clients.RecoveryServices.BackupProtectionContainersClient.Get(ctx, *id) if err != nil { return nil, fmt.Errorf("reading site recovery protection container (%s): %+v", id.String(), err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (BackupProtectionContainerStorageAccountResource) basic(data acceptance.TestData) string { diff --git a/internal/services/recoveryservices/backup_policy_file_share_data_source.go b/internal/services/recoveryservices/backup_policy_file_share_data_source.go index 10b022518b1c..6293e915522a 100644 --- a/internal/services/recoveryservices/backup_policy_file_share_data_source.go +++ b/internal/services/recoveryservices/backup_policy_file_share_data_source.go @@ -3,15 +3,15 @@ package recoveryservices import ( "fmt" "log" - "strings" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceBackupPolicyFileShare() *pluginsdk.Resource { @@ -28,26 +28,24 @@ func dataSourceBackupPolicyFileShare() *pluginsdk.Resource { func dataSourceBackupPolicyFileShareRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).RecoveryServices.ProtectionPoliciesClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - vaultName := d.Get("recovery_vault_name").(string) + id := protectionpolicies.NewBackupPolicyID(subscriptionId, d.Get("resource_group_name").(string), d.Get("recovery_vault_name").(string), d.Get("name").(string)) - log.Printf("[DEBUG] Reading Recovery Service Policy %q (resource group %q)", name, resourceGroup) + log.Printf("[DEBUG] Reading %s", id) - protectionPolicy, err := client.Get(ctx, vaultName, resourceGroup, name) + protectionPolicy, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(protectionPolicy.Response) { - return fmt.Errorf("Error: Backup Policy %q (Resource Group %q) was not found", name, resourceGroup) + if response.WasNotFound(protectionPolicy.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("making Read request on Backup Policy %q (Resource Group %q): %+v", name, resourceGroup, err) + return fmt.Errorf("making Read request on%s: %+v", id, err) } - id := strings.Replace(*protectionPolicy.ID, "Subscriptions", "subscriptions", 1) - d.SetId(id) + d.SetId(id.ID()) return nil } diff --git a/internal/services/recoveryservices/backup_policy_file_share_resource.go b/internal/services/recoveryservices/backup_policy_file_share_resource.go index 45d41c7b9dbd..04210d7ebff8 100644 --- a/internal/services/recoveryservices/backup_policy_file_share_resource.go +++ b/internal/services/recoveryservices/backup_policy_file_share_resource.go @@ -8,19 +8,19 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup" // nolint: staticcheck "github.com/Azure/go-autorest/autorest/date" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/set" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceBackupProtectionPolicyFileShare() *pluginsdk.Resource { @@ -31,7 +31,7 @@ func resourceBackupProtectionPolicyFileShare() *pluginsdk.Resource { Delete: resourceBackupProtectionPolicyFileShareDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.BackupPolicyID(id) + _, err := protectionpolicies.ParseBackupPolicyID(id) return err }), @@ -77,65 +77,61 @@ func resourceBackupProtectionPolicyFileShare() *pluginsdk.Resource { func resourceBackupProtectionPolicyFileShareCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).RecoveryServices.ProtectionPoliciesClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - policyName := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - vaultName := d.Get("recovery_vault_name").(string) + id := protectionpolicies.NewBackupPolicyID(subscriptionId, d.Get("resource_group_name").(string), d.Get("recovery_vault_name").(string), d.Get("name").(string)) - log.Printf("[DEBUG] Creating/updating Recovery Service Protection Policy %s (resource group %q)", policyName, resourceGroup) + log.Printf("[DEBUG] Creating/updating %s", id) // getting this ready now because its shared between *everything*, time is... complicated for this resource timeOfDay := d.Get("backup.0.time").(string) dateOfDay, err := time.Parse(time.RFC3339, fmt.Sprintf("2018-07-30T%s:00Z", timeOfDay)) if err != nil { - return fmt.Errorf("generating time from %q for policy %q (Resource Group %q): %+v", timeOfDay, policyName, resourceGroup, err) + return fmt.Errorf("generating time from %q for %s: %+v", timeOfDay, id, err) } - times := append(make([]date.Time, 0), date.Time{Time: dateOfDay}) + times := append(append(make([]string, 0), date.Time{Time: dateOfDay}.String())) if d.IsNewResource() { - existing, err2 := client.Get(ctx, vaultName, resourceGroup, policyName) - if err2 != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing Recovery Service Protection Policy %q (Resource Group %q): %+v", policyName, resourceGroup, err2) + existing, err := client.Get(ctx, id) + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if existing.ID != nil && *existing.ID != "" { - return tf.ImportAsExistsError("azurerm_backup_policy_file_share", *existing.ID) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_backup_policy_file_share", id.ID()) } } - AzureFileShareProtectionPolicyProperties := &backup.AzureFileShareProtectionPolicy{ - TimeZone: utils.String(d.Get("timezone").(string)), - BackupManagementType: backup.ManagementTypeBasicProtectionPolicyBackupManagementTypeAzureStorage, - WorkLoadType: backup.WorkloadTypeAzureFileShare, - SchedulePolicy: expandBackupProtectionPolicyFileShareSchedule(d, times), - RetentionPolicy: &backup.LongTermRetentionPolicy{ // SimpleRetentionPolicy only has duration property ¯\_(ツ)_/¯ - RetentionPolicyType: backup.RetentionPolicyTypeLongTermRetentionPolicy, - DailySchedule: expandBackupProtectionPolicyFileShareRetentionDaily(d, times), - WeeklySchedule: expandBackupProtectionPolicyFileShareRetentionWeekly(d, times), - MonthlySchedule: expandBackupProtectionPolicyFileShareRetentionMonthly(d, times), - YearlySchedule: expandBackupProtectionPolicyFileShareRetentionYearly(d, times), + AzureFileShareProtectionPolicyProperties := &protectionpolicies.AzureFileShareProtectionPolicy{ + TimeZone: pointer.To(d.Get("timezone").(string)), + WorkLoadType: pointer.To(protectionpolicies.WorkloadTypeAzureFileShare), + SchedulePolicy: expandBackupProtectionPolicyFileShareSchedule(d, times), + RetentionPolicy: &protectionpolicies.LongTermRetentionPolicy{ // SimpleRetentionPolicy only has duration property ¯\_(ツ)_/¯ + DailySchedule: expandBackupProtectionPolicyFileShareRetentionDaily(d, times), + WeeklySchedule: expandBackupProtectionPolicyFileShareRetentionWeekly(d, times), + MonthlySchedule: expandBackupProtectionPolicyFileShareRetentionMonthly(d, times), + YearlySchedule: expandBackupProtectionPolicyFileShareRetentionYearly(d, times), }, } - policy := backup.ProtectionPolicyResource{ + policy := protectionpolicies.ProtectionPolicyResource{ Properties: AzureFileShareProtectionPolicyProperties, } - if _, err = client.CreateOrUpdate(ctx, vaultName, resourceGroup, policyName, policy); err != nil { - return fmt.Errorf("creating/updating Recovery Service Protection Policy %q (Resource Group %q): %+v", policyName, resourceGroup, err) + if _, err = client.CreateOrUpdate(ctx, id, policy); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - resp, err := resourceBackupProtectionPolicyFileShareWaitForUpdate(ctx, client, vaultName, resourceGroup, policyName, d) + _, err = resourceBackupProtectionPolicyFileShareWaitForUpdate(ctx, client, id, d) if err != nil { return err } - id := strings.Replace(*resp.ID, "Subscriptions", "subscriptions", 1) - d.SetId(id) + d.SetId(id.ID()) return resourceBackupProtectionPolicyFileShareRead(d, meta) } @@ -145,67 +141,69 @@ func resourceBackupProtectionPolicyFileShareRead(d *pluginsdk.ResourceData, meta ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.BackupPolicyID(d.Id()) + id, err := protectionpolicies.ParseBackupPolicyID(d.Id()) if err != nil { return err } - log.Printf("[DEBUG] Reading Recovery Service Protection Policy %q (resource group %q)", id.Name, id.ResourceGroup) + log.Printf("[DEBUG] Reading %s", id) - resp, err := client.Get(ctx, id.VaultName, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("making Read request on Recovery Service Protection Policy %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + return fmt.Errorf("making Read request on %s: %+v", id, err) } - d.Set("name", id.Name) - d.Set("resource_group_name", id.ResourceGroup) + d.Set("name", id.BackupPolicyName) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("recovery_vault_name", id.VaultName) - if properties, ok := resp.Properties.AsAzureFileShareProtectionPolicy(); ok && properties != nil { - d.Set("timezone", properties.TimeZone) + if model := resp.Model; model != nil { + if properties, ok := model.Properties.(protectionpolicies.AzureFileShareProtectionPolicy); ok { + d.Set("timezone", properties.TimeZone) - if schedule, ok := properties.SchedulePolicy.AsSimpleSchedulePolicy(); ok && schedule != nil { - if err := d.Set("backup", flattenBackupProtectionPolicyFileShareSchedule(schedule)); err != nil { - return fmt.Errorf("setting `backup`: %+v", err) + if schedule, ok := properties.SchedulePolicy.(protectionpolicies.SimpleSchedulePolicy); ok { + if err := d.Set("backup", flattenBackupProtectionPolicyFileShareSchedule(schedule)); err != nil { + return fmt.Errorf("setting `backup`: %+v", err) + } } - } - if retention, ok := properties.RetentionPolicy.AsLongTermRetentionPolicy(); ok && retention != nil { - if s := retention.DailySchedule; s != nil { - if err := d.Set("retention_daily", flattenBackupProtectionPolicyFileShareRetentionDaily(s)); err != nil { - return fmt.Errorf("setting `retention_daily`: %+v", err) + if retention, ok := properties.RetentionPolicy.(protectionpolicies.LongTermRetentionPolicy); ok { + if s := retention.DailySchedule; s != nil { + if err := d.Set("retention_daily", flattenBackupProtectionPolicyFileShareRetentionDaily(s)); err != nil { + return fmt.Errorf("setting `retention_daily`: %+v", err) + } + } else { + d.Set("retention_daily", nil) } - } else { - d.Set("retention_daily", nil) - } - if s := retention.WeeklySchedule; s != nil { - if err := d.Set("retention_weekly", flattenBackupProtectionPolicyFileShareRetentionWeekly(s)); err != nil { - return fmt.Errorf("setting `retention_weekly`: %+v", err) + if s := retention.WeeklySchedule; s != nil { + if err := d.Set("retention_weekly", flattenBackupProtectionPolicyFileShareRetentionWeekly(s)); err != nil { + return fmt.Errorf("setting `retention_weekly`: %+v", err) + } + } else { + d.Set("retention_weekly", nil) } - } else { - d.Set("retention_weekly", nil) - } - if s := retention.MonthlySchedule; s != nil { - if err := d.Set("retention_monthly", flattenBackupProtectionPolicyFileShareRetentionMonthly(s)); err != nil { - return fmt.Errorf("setting `retention_monthly`: %+v", err) + if s := retention.MonthlySchedule; s != nil { + if err := d.Set("retention_monthly", flattenBackupProtectionPolicyFileShareRetentionMonthly(s)); err != nil { + return fmt.Errorf("setting `retention_monthly`: %+v", err) + } + } else { + d.Set("retention_monthly", nil) } - } else { - d.Set("retention_monthly", nil) - } - if s := retention.YearlySchedule; s != nil { - if err := d.Set("retention_yearly", flattenBackupProtectionPolicyFileShareRetentionYearly(s)); err != nil { - return fmt.Errorf("setting `retention_yearly`: %+v", err) + if s := retention.YearlySchedule; s != nil { + if err := d.Set("retention_yearly", flattenBackupProtectionPolicyFileShareRetentionYearly(s)); err != nil { + return fmt.Errorf("setting `retention_yearly`: %+v", err) + } + } else { + d.Set("retention_yearly", nil) } - } else { - d.Set("retention_yearly", nil) } } } @@ -218,47 +216,34 @@ func resourceBackupProtectionPolicyFileShareDelete(d *pluginsdk.ResourceData, me ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.BackupPolicyID(d.Id()) + id, err := protectionpolicies.ParseBackupPolicyID(d.Id()) if err != nil { return err } - log.Printf("[DEBUG] Deleting Recovery Service Protection Policy %q (resource group %q)", id.Name, id.ResourceGroup) + log.Printf("[DEBUG] Deleting %s", id) - future, err := client.Delete(ctx, id.VaultName, id.ResourceGroup, id.Name) - if err != nil { + if err = client.DeleteThenPoll(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", *id, err) } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for deletion of %s: %+v", *id, err) - } - - resp, err := future.Result(*client) - if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("issuing delete request for Recovery Service Protection Policy %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } - } - - if _, err := resourceBackupProtectionPolicyFileShareWaitForDeletion(ctx, client, id.VaultName, id.ResourceGroup, id.Name, d); err != nil { + if _, err := resourceBackupProtectionPolicyFileShareWaitForDeletion(ctx, client, *id, d); err != nil { return err } return nil } -func expandBackupProtectionPolicyFileShareSchedule(d *pluginsdk.ResourceData, times []date.Time) *backup.SimpleSchedulePolicy { +func expandBackupProtectionPolicyFileShareSchedule(d *pluginsdk.ResourceData, times []string) *protectionpolicies.SimpleSchedulePolicy { if bb, ok := d.Get("backup").([]interface{}); ok && len(bb) > 0 { block := bb[0].(map[string]interface{}) - schedule := backup.SimpleSchedulePolicy{ // LongTermSchedulePolicy has no properties - SchedulePolicyType: backup.SchedulePolicyTypeSimpleSchedulePolicy, - ScheduleRunTimes: ×, + schedule := protectionpolicies.SimpleSchedulePolicy{ // LongTermSchedulePolicy has no properties + ScheduleRunTimes: ×, } if v, ok := block["frequency"].(string); ok { - schedule.ScheduleRunFrequency = backup.ScheduleRunType(v) + schedule.ScheduleRunFrequency = pointer.To(protectionpolicies.ScheduleRunType(v)) } return &schedule @@ -267,15 +252,15 @@ func expandBackupProtectionPolicyFileShareSchedule(d *pluginsdk.ResourceData, ti return nil } -func expandBackupProtectionPolicyFileShareRetentionDaily(d *pluginsdk.ResourceData, times []date.Time) *backup.DailyRetentionSchedule { +func expandBackupProtectionPolicyFileShareRetentionDaily(d *pluginsdk.ResourceData, times []string) *protectionpolicies.DailyRetentionSchedule { if rb, ok := d.Get("retention_daily").([]interface{}); ok && len(rb) > 0 { block := rb[0].(map[string]interface{}) - return &backup.DailyRetentionSchedule{ + return &protectionpolicies.DailyRetentionSchedule{ RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(int32(block["count"].(int))), - DurationType: backup.RetentionDurationTypeDays, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(int64(block["count"].(int))), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeDays), }, } } @@ -283,22 +268,22 @@ func expandBackupProtectionPolicyFileShareRetentionDaily(d *pluginsdk.ResourceDa return nil } -func expandBackupProtectionPolicyFileShareRetentionWeekly(d *pluginsdk.ResourceData, times []date.Time) *backup.WeeklyRetentionSchedule { +func expandBackupProtectionPolicyFileShareRetentionWeekly(d *pluginsdk.ResourceData, times []string) *protectionpolicies.WeeklyRetentionSchedule { if rb, ok := d.Get("retention_weekly").([]interface{}); ok && len(rb) > 0 { block := rb[0].(map[string]interface{}) - retention := backup.WeeklyRetentionSchedule{ + retention := protectionpolicies.WeeklyRetentionSchedule{ RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(int32(block["count"].(int))), - DurationType: backup.RetentionDurationTypeWeeks, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(int64(block["count"].(int))), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeWeeks), }, } if v, ok := block["weekdays"].(*pluginsdk.Set); ok { - days := make([]backup.DayOfWeek, 0) + days := make([]protectionpolicies.DayOfWeek, 0) for _, day := range v.List() { - days = append(days, backup.DayOfWeek(day.(string))) + days = append(days, protectionpolicies.DayOfWeek(day.(string))) } retention.DaysOfTheWeek = &days } @@ -309,18 +294,16 @@ func expandBackupProtectionPolicyFileShareRetentionWeekly(d *pluginsdk.ResourceD return nil } -func expandBackupProtectionPolicyFileShareRetentionMonthly(d *pluginsdk.ResourceData, times []date.Time) *backup.MonthlyRetentionSchedule { +func expandBackupProtectionPolicyFileShareRetentionMonthly(d *pluginsdk.ResourceData, times []string) *protectionpolicies.MonthlyRetentionSchedule { if rb, ok := d.Get("retention_monthly").([]interface{}); ok && len(rb) > 0 { block := rb[0].(map[string]interface{}) - retention := backup.MonthlyRetentionSchedule{ - RetentionScheduleFormatType: backup.RetentionScheduleFormatWeekly, // this is always weekly ¯\_(ツ)_/¯ - RetentionScheduleDaily: nil, // and this is always nil.. - RetentionScheduleWeekly: expandBackupProtectionPolicyFileShareRetentionWeeklyFormat(block), - RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(int32(block["count"].(int))), - DurationType: backup.RetentionDurationTypeMonths, + retention := protectionpolicies.MonthlyRetentionSchedule{ + RetentionScheduleDaily: nil, // and this is always nil.. + RetentionScheduleWeekly: expandBackupProtectionPolicyFileShareRetentionWeeklyFormat(block), + RetentionTimes: ×, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(int64(block["count"].(int))), }, } @@ -330,25 +313,25 @@ func expandBackupProtectionPolicyFileShareRetentionMonthly(d *pluginsdk.Resource return nil } -func expandBackupProtectionPolicyFileShareRetentionYearly(d *pluginsdk.ResourceData, times []date.Time) *backup.YearlyRetentionSchedule { +func expandBackupProtectionPolicyFileShareRetentionYearly(d *pluginsdk.ResourceData, times []string) *protectionpolicies.YearlyRetentionSchedule { if rb, ok := d.Get("retention_yearly").([]interface{}); ok && len(rb) > 0 { block := rb[0].(map[string]interface{}) - retention := backup.YearlyRetentionSchedule{ - RetentionScheduleFormatType: backup.RetentionScheduleFormatWeekly, // this is always weekly ¯\_(ツ)_/¯ - RetentionScheduleDaily: nil, // and this is always nil.. + retention := protectionpolicies.YearlyRetentionSchedule{ + RetentionScheduleFormatType: pointer.To(protectionpolicies.RetentionScheduleFormatWeekly), // this is always weekly ¯\_(ツ)_/¯ + RetentionScheduleDaily: nil, // and this is always nil.. RetentionScheduleWeekly: expandBackupProtectionPolicyFileShareRetentionWeeklyFormat(block), RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(int32(block["count"].(int))), - DurationType: backup.RetentionDurationTypeYears, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(int64(block["count"].(int))), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeYears), }, } if v, ok := block["months"].(*pluginsdk.Set); ok { - months := make([]backup.MonthOfYear, 0) + months := make([]protectionpolicies.MonthOfYear, 0) for _, month := range v.List() { - months = append(months, backup.MonthOfYear(month.(string))) + months = append(months, protectionpolicies.MonthOfYear(month.(string))) } retention.MonthsOfYear = &months } @@ -359,21 +342,21 @@ func expandBackupProtectionPolicyFileShareRetentionYearly(d *pluginsdk.ResourceD return nil } -func expandBackupProtectionPolicyFileShareRetentionWeeklyFormat(block map[string]interface{}) *backup.WeeklyRetentionFormat { - weekly := backup.WeeklyRetentionFormat{} +func expandBackupProtectionPolicyFileShareRetentionWeeklyFormat(block map[string]interface{}) *protectionpolicies.WeeklyRetentionFormat { + weekly := protectionpolicies.WeeklyRetentionFormat{} if v, ok := block["weekdays"].(*pluginsdk.Set); ok { - days := make([]backup.DayOfWeek, 0) + days := make([]protectionpolicies.DayOfWeek, 0) for _, day := range v.List() { - days = append(days, backup.DayOfWeek(day.(string))) + days = append(days, protectionpolicies.DayOfWeek(day.(string))) } weekly.DaysOfTheWeek = &days } if v, ok := block["weeks"].(*pluginsdk.Set); ok { - weeks := make([]backup.WeekOfMonth, 0) + weeks := make([]protectionpolicies.WeekOfMonth, 0) for _, week := range v.List() { - weeks = append(weeks, backup.WeekOfMonth(week.(string))) + weeks = append(weeks, protectionpolicies.WeekOfMonth(week.(string))) } weekly.WeeksOfTheMonth = &weeks } @@ -381,19 +364,19 @@ func expandBackupProtectionPolicyFileShareRetentionWeeklyFormat(block map[string return &weekly } -func flattenBackupProtectionPolicyFileShareSchedule(schedule *backup.SimpleSchedulePolicy) []interface{} { +func flattenBackupProtectionPolicyFileShareSchedule(schedule protectionpolicies.SimpleSchedulePolicy) []interface{} { block := map[string]interface{}{} - block["frequency"] = string(schedule.ScheduleRunFrequency) + block["frequency"] = string(pointer.From(schedule.ScheduleRunFrequency)) if times := schedule.ScheduleRunTimes; times != nil && len(*times) > 0 { - block["time"] = (*times)[0].Format("15:04") + block["time"] = (*times)[0] } return []interface{}{block} } -func flattenBackupProtectionPolicyFileShareRetentionDaily(daily *backup.DailyRetentionSchedule) []interface{} { +func flattenBackupProtectionPolicyFileShareRetentionDaily(daily *protectionpolicies.DailyRetentionSchedule) []interface{} { block := map[string]interface{}{} if duration := daily.RetentionDuration; duration != nil { @@ -405,7 +388,7 @@ func flattenBackupProtectionPolicyFileShareRetentionDaily(daily *backup.DailyRet return []interface{}{block} } -func flattenBackupProtectionPolicyFileShareRetentionWeekly(weekly *backup.WeeklyRetentionSchedule) []interface{} { +func flattenBackupProtectionPolicyFileShareRetentionWeekly(weekly *protectionpolicies.WeeklyRetentionSchedule) []interface{} { block := map[string]interface{}{} if duration := weekly.RetentionDuration; duration != nil { @@ -425,7 +408,7 @@ func flattenBackupProtectionPolicyFileShareRetentionWeekly(weekly *backup.Weekly return []interface{}{block} } -func flattenBackupProtectionPolicyFileShareRetentionMonthly(monthly *backup.MonthlyRetentionSchedule) []interface{} { +func flattenBackupProtectionPolicyFileShareRetentionMonthly(monthly *protectionpolicies.MonthlyRetentionSchedule) []interface{} { block := map[string]interface{}{} if duration := monthly.RetentionDuration; duration != nil { @@ -441,7 +424,7 @@ func flattenBackupProtectionPolicyFileShareRetentionMonthly(monthly *backup.Mont return []interface{}{block} } -func flattenBackupProtectionPolicyFileShareRetentionYearly(yearly *backup.YearlyRetentionSchedule) []interface{} { +func flattenBackupProtectionPolicyFileShareRetentionYearly(yearly *protectionpolicies.YearlyRetentionSchedule) []interface{} { block := map[string]interface{}{} if duration := yearly.RetentionDuration; duration != nil { @@ -465,7 +448,7 @@ func flattenBackupProtectionPolicyFileShareRetentionYearly(yearly *backup.Yearly return []interface{}{block} } -func flattenBackupProtectionPolicyFileShareRetentionWeeklyFormat(retention *backup.WeeklyRetentionFormat) (weekdays, weeks *pluginsdk.Set) { +func flattenBackupProtectionPolicyFileShareRetentionWeeklyFormat(retention *protectionpolicies.WeeklyRetentionFormat) (weekdays, weeks *pluginsdk.Set) { if days := retention.DaysOfTheWeek; days != nil { slice := make([]interface{}, 0) for _, d := range *days { @@ -485,13 +468,13 @@ func flattenBackupProtectionPolicyFileShareRetentionWeeklyFormat(retention *back return weekdays, weeks } -func resourceBackupProtectionPolicyFileShareWaitForUpdate(ctx context.Context, client *backup.ProtectionPoliciesClient, vaultName, resourceGroup, policyName string, d *pluginsdk.ResourceData) (backup.ProtectionPolicyResource, error) { +func resourceBackupProtectionPolicyFileShareWaitForUpdate(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) (protectionpolicies.ProtectionPolicyResource, error) { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, Pending: []string{"NotFound"}, Target: []string{"Found"}, - Refresh: resourceBackupProtectionPolicyFileShareRefreshFunc(ctx, client, vaultName, resourceGroup, policyName), + Refresh: resourceBackupProtectionPolicyFileShareRefreshFunc(ctx, client, id), } if d.IsNewResource() { @@ -502,39 +485,39 @@ func resourceBackupProtectionPolicyFileShareWaitForUpdate(ctx context.Context, c resp, err := state.WaitForStateContext(ctx) if err != nil { - return resp.(backup.ProtectionPolicyResource), fmt.Errorf("waiting for the Recovery Service Protection Policy %q to update (Resource Group %q): %+v", policyName, resourceGroup, err) + return resp.(protectionpolicies.ProtectionPolicyResource), fmt.Errorf("waiting for update %s: %+v", id, err) } - return resp.(backup.ProtectionPolicyResource), nil + return resp.(protectionpolicies.ProtectionPolicyResource), nil } -func resourceBackupProtectionPolicyFileShareWaitForDeletion(ctx context.Context, client *backup.ProtectionPoliciesClient, vaultName, resourceGroup, policyName string, d *pluginsdk.ResourceData) (backup.ProtectionPolicyResource, error) { +func resourceBackupProtectionPolicyFileShareWaitForDeletion(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) (protectionpolicies.ProtectionPolicyResource, error) { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, Pending: []string{"Found"}, Target: []string{"NotFound"}, - Refresh: resourceBackupProtectionPolicyFileShareRefreshFunc(ctx, client, vaultName, resourceGroup, policyName), + Refresh: resourceBackupProtectionPolicyFileShareRefreshFunc(ctx, client, id), Timeout: d.Timeout(pluginsdk.TimeoutDelete), } resp, err := state.WaitForStateContext(ctx) if err != nil { - return resp.(backup.ProtectionPolicyResource), fmt.Errorf("waiting for the Recovery Service Protection Policy %q to be missing (Resource Group %q): %+v", policyName, resourceGroup, err) + return resp.(protectionpolicies.ProtectionPolicyResource), fmt.Errorf("waiting for delete to finish for %s: %+v", id, err) } - return resp.(backup.ProtectionPolicyResource), nil + return resp.(protectionpolicies.ProtectionPolicyResource), nil } -func resourceBackupProtectionPolicyFileShareRefreshFunc(ctx context.Context, client *backup.ProtectionPoliciesClient, vaultName, resourceGroup, policyName string) pluginsdk.StateRefreshFunc { +func resourceBackupProtectionPolicyFileShareRefreshFunc(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId) pluginsdk.StateRefreshFunc { return func() (interface{}, string, error) { - resp, err := client.Get(ctx, vaultName, resourceGroup, policyName) + resp, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return resp, "NotFound", nil } - return resp, "Error", fmt.Errorf("making Read request on Recovery Service Protection Policy %q (Resource Group %q): %+v", policyName, resourceGroup, err) + return resp, "Error", fmt.Errorf("making Read request on %s: %+v", id, err) } return resp, "Found", nil @@ -579,7 +562,7 @@ func resourceBackupProtectionPolicyFileShareSchema() map[string]*pluginsdk.Schem Required: true, DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: validation.StringInSlice([]string{ - string(backup.ScheduleRunTypeDaily), + string(protectionpolicies.ScheduleRunTypeDaily), }, false), }, @@ -655,11 +638,11 @@ func resourceBackupProtectionPolicyFileShareSchema() map[string]*pluginsdk.Schem Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, ValidateFunc: validation.StringInSlice([]string{ - string(backup.WeekOfMonthFirst), - string(backup.WeekOfMonthSecond), - string(backup.WeekOfMonthThird), - string(backup.WeekOfMonthFourth), - string(backup.WeekOfMonthLast), + string(protectionpolicies.WeekOfMonthFirst), + string(protectionpolicies.WeekOfMonthSecond), + string(protectionpolicies.WeekOfMonthThird), + string(protectionpolicies.WeekOfMonthFourth), + string(protectionpolicies.WeekOfMonthLast), }, false), }, }, @@ -708,11 +691,11 @@ func resourceBackupProtectionPolicyFileShareSchema() map[string]*pluginsdk.Schem Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, ValidateFunc: validation.StringInSlice([]string{ - string(backup.WeekOfMonthFirst), - string(backup.WeekOfMonthSecond), - string(backup.WeekOfMonthThird), - string(backup.WeekOfMonthFourth), - string(backup.WeekOfMonthLast), + string(protectionpolicies.WeekOfMonthFirst), + string(protectionpolicies.WeekOfMonthSecond), + string(protectionpolicies.WeekOfMonthThird), + string(protectionpolicies.WeekOfMonthFourth), + string(protectionpolicies.WeekOfMonthLast), }, false), }, }, diff --git a/internal/services/recoveryservices/backup_policy_file_share_resource_test.go b/internal/services/recoveryservices/backup_policy_file_share_resource_test.go index bcd35ef94a89..0e9a627193b6 100644 --- a/internal/services/recoveryservices/backup_policy_file_share_resource_test.go +++ b/internal/services/recoveryservices/backup_policy_file_share_resource_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -332,17 +332,17 @@ func TestAccBackupProtectionPolicyFileShare_updateDailyToPartial(t *testing.T) { } func (t BackupProtectionPolicyFileShareResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.BackupPolicyID(state.ID) + id, err := protectionpolicies.ParseBackupPolicyID(state.ID) if err != nil { return nil, err } - resp, err := clients.RecoveryServices.ProtectionPoliciesClient.Get(ctx, id.VaultName, id.ResourceGroup, id.Name) + resp, err := clients.RecoveryServices.ProtectionPoliciesClient.Get(ctx, *id) if err != nil { return nil, fmt.Errorf("reading Recovery Service Protection Policy (%s): %+v", id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (BackupProtectionPolicyFileShareResource) template(data acceptance.TestData) string { diff --git a/internal/services/recoveryservices/backup_policy_vm_data_source.go b/internal/services/recoveryservices/backup_policy_vm_data_source.go index ec0dc90d045a..b2c3d22e3e50 100644 --- a/internal/services/recoveryservices/backup_policy_vm_data_source.go +++ b/internal/services/recoveryservices/backup_policy_vm_data_source.go @@ -3,15 +3,15 @@ package recoveryservices import ( "fmt" "log" - "strings" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceBackupPolicyVm() *pluginsdk.Resource { @@ -28,30 +28,28 @@ func dataSourceBackupPolicyVm() *pluginsdk.Resource { func dataSourceBackupPolicyVmRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).RecoveryServices.ProtectionPoliciesClient + subscriptionid := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - vaultName := d.Get("recovery_vault_name").(string) + id := protectionpolicies.NewBackupPolicyID(subscriptionid, d.Get("resource_group_name").(string), d.Get("recovery_vault_name").(string), d.Get("name").(string)) - log.Printf("[DEBUG] Reading Recovery Service Policy %q (resource group %q)", name, resourceGroup) + log.Printf("[DEBUG] Reading %s", id) - protectionPolicy, err := client.Get(ctx, vaultName, resourceGroup, name) + protectionPolicy, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(protectionPolicy.Response) { - return fmt.Errorf("Error: Backup Policy %q (Resource Group %q) was not found", name, resourceGroup) + if response.WasNotFound(protectionPolicy.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("making Read request on Backup Policy %q (Resource Group %q): %+v", name, resourceGroup, err) + return fmt.Errorf("making Read request on %s: %+v", id, err) } - if protectionPolicy.ID == nil || *protectionPolicy.ID == "" { - return fmt.Errorf("retrieving Backup Policy VM %q (Vault Name %q /Resource Group %q): ID was nil or empty", name, vaultName, resourceGroup) + if protectionPolicy.Model == nil { + return fmt.Errorf("retrieving %s: model was nil", id) } - id := strings.Replace(*protectionPolicy.ID, "Subscriptions", "subscriptions", 1) - d.SetId(id) + d.SetId(id.ID()) return nil } diff --git a/internal/services/recoveryservices/backup_policy_vm_resource.go b/internal/services/recoveryservices/backup_policy_vm_resource.go index a5b1e996d823..2b1aa331ab60 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource.go @@ -5,16 +5,16 @@ import ( "fmt" "log" "regexp" - "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup" // nolint: staticcheck "github.com/Azure/go-autorest/autorest/date" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/set" @@ -32,7 +32,7 @@ func resourceBackupProtectionPolicyVM() *pluginsdk.Resource { Delete: resourceBackupProtectionPolicyVMDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.BackupPolicyID(id) + _, err := protectionpolicies.ParseBackupPolicyID(id) return err }), @@ -53,7 +53,7 @@ func resourceBackupProtectionPolicyVM() *pluginsdk.Resource { frequency, _ := diff.GetOk("backup.0.frequency") switch frequency.(string) { - case string(backup.ScheduleRunTypeHourly): + case string(protectionpolicies.ScheduleRunTypeHourly): if !hasDaily { return fmt.Errorf("`retention_daily` must be set when backup.0.frequency is hourly") } @@ -61,7 +61,7 @@ func resourceBackupProtectionPolicyVM() *pluginsdk.Resource { if _, ok := diff.GetOk("backup.0.weekdays"); ok { return fmt.Errorf("`backup.0.weekdays` should be not set when backup.0.frequency is hourly") } - case string(backup.ScheduleRunTypeDaily): + case string(protectionpolicies.ScheduleRunTypeDaily): if !hasDaily { return fmt.Errorf("`retention_daily` must be set when backup.0.frequency is daily") } @@ -77,7 +77,7 @@ func resourceBackupProtectionPolicyVM() *pluginsdk.Resource { if _, ok := diff.GetOk("backup.0.hour_duration"); ok { return fmt.Errorf("`backup.0.hour_duration` should be not set when backup.0.frequency is daily") } - case string(backup.ScheduleRunTypeWeekly): + case string(protectionpolicies.ScheduleRunTypeWeekly): if hasDaily { return fmt.Errorf("`retention_daily` must be not set when backup.0.frequency is weekly") } @@ -102,33 +102,32 @@ func resourceBackupProtectionPolicyVM() *pluginsdk.Resource { func resourceBackupProtectionPolicyVMCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).RecoveryServices.ProtectionPoliciesClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - policyName := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - vaultName := d.Get("recovery_vault_name").(string) + id := protectionpolicies.NewBackupPolicyID(subscriptionId, d.Get("resource_group_name").(string), d.Get("recovery_vault_name").(string), d.Get("name").(string)) - log.Printf("[DEBUG] Creating/updating Azure Backup Protection Policy %s (resource group %q)", policyName, resourceGroup) + log.Printf("[DEBUG] Creating/updating %s", id) // getting this ready now because its shared between *everything*, time is... complicated for this resource timeOfDay := d.Get("backup.0.time").(string) dateOfDay, err := time.Parse(time.RFC3339, fmt.Sprintf("2018-07-30T%s:00Z", timeOfDay)) if err != nil { - return fmt.Errorf("generating time from %q for policy %q (Resource Group %q): %+v", timeOfDay, policyName, resourceGroup, err) + return fmt.Errorf("generating time from %q for %s: %+v", timeOfDay, id, err) } - times := append(make([]date.Time, 0), date.Time{Time: dateOfDay}) + times := append(make([]string, 0), date.Time{Time: dateOfDay}.String()) if d.IsNewResource() { - existing, err2 := client.Get(ctx, vaultName, resourceGroup, policyName) - if err2 != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing Azure Backup Protection Policy %q (Resource Group %q): %+v", policyName, resourceGroup, err2) + existing, err := client.Get(ctx, id) + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if existing.ID != nil && *existing.ID != "" { - return tf.ImportAsExistsError("azurerm_backup_policy_vm", *existing.ID) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_backup_policy_vm", id.ID()) } } @@ -142,50 +141,43 @@ func resourceBackupProtectionPolicyVMCreateUpdate(d *pluginsdk.ResourceData, met return err } - policyType := backup.IAASVMPolicyType(d.Get("policy_type").(string)) - vmProtectionPolicyProperties := &backup.AzureIaaSVMProtectionPolicy{ - TimeZone: utils.String(d.Get("timezone").(string)), - BackupManagementType: backup.ManagementTypeBasicProtectionPolicyBackupManagementTypeAzureIaasVM, - PolicyType: policyType, - SchedulePolicy: *schedulePolicy, - InstantRPDetails: expandBackupProtectionPolicyVMResourceGroup(d), - RetentionPolicy: &backup.LongTermRetentionPolicy{ // SimpleRetentionPolicy only has duration property ¯\_(ツ)_/¯ - RetentionPolicyType: backup.RetentionPolicyTypeLongTermRetentionPolicy, - DailySchedule: expandBackupProtectionPolicyVMRetentionDaily(d, times), - WeeklySchedule: expandBackupProtectionPolicyVMRetentionWeekly(d, times), - MonthlySchedule: expandBackupProtectionPolicyVMRetentionMonthly(d, times), - YearlySchedule: expandBackupProtectionPolicyVMRetentionYearly(d, times), + policyType := protectionpolicies.IAASVMPolicyType(d.Get("policy_type").(string)) + vmProtectionPolicyProperties := &protectionpolicies.AzureIaaSVMProtectionPolicy{ + TimeZone: utils.String(d.Get("timezone").(string)), + PolicyType: pointer.To(policyType), + SchedulePolicy: schedulePolicy, + InstantRPDetails: expandBackupProtectionPolicyVMResourceGroup(d), + RetentionPolicy: &protectionpolicies.LongTermRetentionPolicy{ // SimpleRetentionPolicy only has duration property ¯\_(ツ)_/¯ + DailySchedule: expandBackupProtectionPolicyVMRetentionDaily(d, times), + WeeklySchedule: expandBackupProtectionPolicyVMRetentionWeekly(d, times), + MonthlySchedule: expandBackupProtectionPolicyVMRetentionMonthly(d, times), + YearlySchedule: expandBackupProtectionPolicyVMRetentionYearly(d, times), }, } if d.HasChange("instant_restore_retention_days") { days := d.Get("instant_restore_retention_days").(int) - if backup.IAASVMPolicyTypeV1 == policyType && days > 5 { + if protectionpolicies.IAASVMPolicyTypeVOne == policyType && days > 5 { return fmt.Errorf("`instant_restore_retention_days` must be less than or equal to `5` when `policy_type` is `V1`") } - vmProtectionPolicyProperties.InstantRpRetentionRangeInDays = utils.Int32(int32(days)) + vmProtectionPolicyProperties.InstantRpRetentionRangeInDays = pointer.To(int64(days)) } - policy := backup.ProtectionPolicyResource{ + policy := protectionpolicies.ProtectionPolicyResource{ Properties: vmProtectionPolicyProperties, } - if _, err = client.CreateOrUpdate(ctx, vaultName, resourceGroup, policyName, policy); err != nil { - return fmt.Errorf("creating/updating Azure Backup Protection Policy %q (Resource Group %q): %+v", policyName, resourceGroup, err) + if _, err = client.CreateOrUpdate(ctx, id, policy); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - resp, err := resourceBackupProtectionPolicyVMWaitForUpdate(ctx, client, vaultName, resourceGroup, policyName, d) + _, err = resourceBackupProtectionPolicyVMWaitForUpdate(ctx, client, id, d) if err != nil { return err } - if resp.ID == nil || *resp.ID == "" { - return fmt.Errorf("retrieving Backup Policy VM %q (Vault Name %q /Resource Group %q): ID was nil or empty", policyName, vaultName, resourceGroup) - } - - id := strings.Replace(*resp.ID, "Subscriptions", "subscriptions", 1) - d.SetId(id) + d.SetId(id.ID()) return resourceBackupProtectionPolicyVMRead(d, meta) } @@ -195,85 +187,87 @@ func resourceBackupProtectionPolicyVMRead(d *pluginsdk.ResourceData, meta interf ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.BackupPolicyID(d.Id()) + id, err := protectionpolicies.ParseBackupPolicyID(d.Id()) if err != nil { return err } - log.Printf("[DEBUG] Reading Azure Backup Protection Policy %q (resource group %q)", id.Name, id.ResourceGroup) + log.Printf("[DEBUG] Reading %s", id) - resp, err := client.Get(ctx, id.VaultName, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("making Read request on Azure Backup Protection Policy %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + return fmt.Errorf("making Read request on %s: %+v", id, err) } - d.Set("name", id.Name) - d.Set("resource_group_name", id.ResourceGroup) + d.Set("name", id.BackupPolicyName) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("recovery_vault_name", id.VaultName) - if properties, ok := resp.Properties.AsAzureIaaSVMProtectionPolicy(); ok && properties != nil { - d.Set("timezone", properties.TimeZone) - d.Set("instant_restore_retention_days", properties.InstantRpRetentionRangeInDays) + if model := resp.Model; model != nil { + if properties, ok := model.Properties.(protectionpolicies.AzureIaaSVMProtectionPolicy); ok { + d.Set("timezone", properties.TimeZone) + d.Set("instant_restore_retention_days", properties.InstantRpRetentionRangeInDays) - if schedule, ok := properties.SchedulePolicy.AsSimpleSchedulePolicy(); ok && schedule != nil { - if err := d.Set("backup", flattenBackupProtectionPolicyVMSchedule(schedule)); err != nil { - return fmt.Errorf("setting `backup`: %+v", err) + if schedule, ok := properties.SchedulePolicy.(protectionpolicies.SimpleSchedulePolicy); ok { + if err := d.Set("backup", flattenBackupProtectionPolicyVMSchedule(schedule)); err != nil { + return fmt.Errorf("setting `backup`: %+v", err) + } } - } - if schedule, ok := properties.SchedulePolicy.AsSimpleSchedulePolicyV2(); ok && schedule != nil { - if err := d.Set("backup", flattenBackupProtectionPolicyVMScheduleV2(schedule)); err != nil { - return fmt.Errorf("setting `backup`: %+v", err) + if schedule, ok := properties.SchedulePolicy.(protectionpolicies.SimpleSchedulePolicyV2); ok { + if err := d.Set("backup", flattenBackupProtectionPolicyVMScheduleV2(schedule)); err != nil { + return fmt.Errorf("setting `backup`: %+v", err) + } } - } - - policyType := string(backup.IAASVMPolicyTypeV1) - if properties.PolicyType != "" { - policyType = string(properties.PolicyType) - } - d.Set("policy_type", policyType) - if retention, ok := properties.RetentionPolicy.AsLongTermRetentionPolicy(); ok && retention != nil { - if s := retention.DailySchedule; s != nil { - if err := d.Set("retention_daily", flattenBackupProtectionPolicyVMRetentionDaily(s)); err != nil { - return fmt.Errorf("setting `retention_daily`: %+v", err) - } - } else { - d.Set("retention_daily", nil) + policyType := string(protectionpolicies.IAASVMPolicyTypeVOne) + if pointer.From(properties.PolicyType) != "" { + policyType = string(pointer.From(properties.PolicyType)) } + d.Set("policy_type", policyType) + + if retention, ok := properties.RetentionPolicy.(protectionpolicies.LongTermRetentionPolicy); ok { + if s := retention.DailySchedule; s != nil { + if err := d.Set("retention_daily", flattenBackupProtectionPolicyVMRetentionDaily(s)); err != nil { + return fmt.Errorf("setting `retention_daily`: %+v", err) + } + } else { + d.Set("retention_daily", nil) + } - if s := retention.WeeklySchedule; s != nil { - if err := d.Set("retention_weekly", flattenBackupProtectionPolicyVMRetentionWeekly(s)); err != nil { - return fmt.Errorf("setting `retention_weekly`: %+v", err) + if s := retention.WeeklySchedule; s != nil { + if err := d.Set("retention_weekly", flattenBackupProtectionPolicyVMRetentionWeekly(s)); err != nil { + return fmt.Errorf("setting `retention_weekly`: %+v", err) + } + } else { + d.Set("retention_weekly", nil) } - } else { - d.Set("retention_weekly", nil) - } - if s := retention.MonthlySchedule; s != nil { - if err := d.Set("retention_monthly", flattenBackupProtectionPolicyVMRetentionMonthly(s)); err != nil { - return fmt.Errorf("setting `retention_monthly`: %+v", err) + if s := retention.MonthlySchedule; s != nil { + if err := d.Set("retention_monthly", flattenBackupProtectionPolicyVMRetentionMonthly(s)); err != nil { + return fmt.Errorf("setting `retention_monthly`: %+v", err) + } + } else { + d.Set("retention_monthly", nil) } - } else { - d.Set("retention_monthly", nil) - } - if s := retention.YearlySchedule; s != nil { - if err := d.Set("retention_yearly", flattenBackupProtectionPolicyVMRetentionYearly(s)); err != nil { - return fmt.Errorf("setting `retention_yearly`: %+v", err) + if s := retention.YearlySchedule; s != nil { + if err := d.Set("retention_yearly", flattenBackupProtectionPolicyVMRetentionYearly(s)); err != nil { + return fmt.Errorf("setting `retention_yearly`: %+v", err) + } + } else { + d.Set("retention_yearly", nil) } - } else { - d.Set("retention_yearly", nil) } - } - if instantRPDetail := properties.InstantRPDetails; instantRPDetail != nil { - d.Set("instant_restore_resource_group", flattenBackupProtectionPolicyVMResourceGroup(*instantRPDetail)) + if instantRPDetail := properties.InstantRPDetails; instantRPDetail != nil { + d.Set("instant_restore_resource_group", flattenBackupProtectionPolicyVMResourceGroup(*instantRPDetail)) + } } } @@ -285,70 +279,55 @@ func resourceBackupProtectionPolicyVMDelete(d *pluginsdk.ResourceData, meta inte ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.BackupPolicyID(d.Id()) + id, err := protectionpolicies.ParseBackupPolicyID(d.Id()) if err != nil { return err } - log.Printf("[DEBUG] Deleting Azure Backup Protected Item %q (resource group %q)", id.Name, id.ResourceGroup) + log.Printf("[DEBUG] Deleting %s", id) - future, err := client.Delete(ctx, id.VaultName, id.ResourceGroup, id.Name) - if err != nil { + if err = client.DeleteThenPoll(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", *id, err) } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for deletion of %s: %+v", *id, err) - } - - resp, err := future.Result(*client) - if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("issuing delete request for Azure Backup Protection Policy %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } - } - - if _, err := resourceBackupProtectionPolicyVMWaitForDeletion(ctx, client, id.VaultName, id.ResourceGroup, id.Name, d); err != nil { + if _, err := resourceBackupProtectionPolicyVMWaitForDeletion(ctx, client, *id, d); err != nil { return err } return nil } -func expandBackupProtectionPolicyVMSchedule(d *pluginsdk.ResourceData, times []date.Time) (*backup.BasicSchedulePolicy, error) { +func expandBackupProtectionPolicyVMSchedule(d *pluginsdk.ResourceData, times []string) (protectionpolicies.SchedulePolicy, error) { if bb, ok := d.Get("backup").([]interface{}); ok && len(bb) > 0 { block := bb[0].(map[string]interface{}) policyType := d.Get("policy_type").(string) - if policyType == string(backup.IAASVMPolicyTypeV1) { - schedule := backup.SimpleSchedulePolicy{ // LongTermSchedulePolicy has no properties - SchedulePolicyType: backup.SchedulePolicyTypeSimpleSchedulePolicy, - ScheduleRunTimes: ×, + if policyType == string(protectionpolicies.IAASVMPolicyTypeVOne) { + schedule := protectionpolicies.SimpleSchedulePolicy{ // LongTermSchedulePolicy has no properties + ScheduleRunTimes: ×, } if v, ok := block["frequency"].(string); ok { - schedule.ScheduleRunFrequency = backup.ScheduleRunType(v) + schedule.ScheduleRunFrequency = pointer.To(protectionpolicies.ScheduleRunType(v)) } if v, ok := block["weekdays"].(*pluginsdk.Set); ok { - days := make([]backup.DayOfWeek, 0) + days := make([]protectionpolicies.DayOfWeek, 0) for _, day := range v.List() { - days = append(days, backup.DayOfWeek(day.(string))) + days = append(days, protectionpolicies.DayOfWeek(day.(string))) } schedule.ScheduleRunDays = &days } - result, _ := schedule.AsBasicSchedulePolicy() - return &result, nil + return schedule, nil } else { frequency := block["frequency"].(string) - schedule := backup.SimpleSchedulePolicyV2{ - SchedulePolicyType: backup.SchedulePolicyTypeSimpleSchedulePolicyV2, - ScheduleRunFrequency: backup.ScheduleRunType(frequency), + schedule := protectionpolicies.SimpleSchedulePolicyV2{ + ScheduleRunFrequency: pointer.To(protectionpolicies.ScheduleRunType(frequency)), } switch frequency { - case string(backup.ScheduleRunTypeHourly): + case string(protectionpolicies.ScheduleRunTypeHourly): interval, ok := block["hour_interval"].(int) if !ok { return nil, fmt.Errorf("`hour_interval` must be specified when `backup.0.frequency` is `Hourly`") @@ -373,27 +352,27 @@ func expandBackupProtectionPolicyVMSchedule(d *pluginsdk.ResourceData, times []d return nil, fmt.Errorf("`hour_duration` must be multiplier of `hour_interval`") } - schedule.HourlySchedule = &backup.HourlySchedule{ - Interval: utils.Int32(int32(interval)), + schedule.HourlySchedule = &protectionpolicies.HourlySchedule{ + Interval: pointer.To(int64(interval)), ScheduleWindowStartTime: ×[0], - ScheduleWindowDuration: utils.Int32(int32(duration)), + ScheduleWindowDuration: pointer.To(int64(duration)), } - case string(backup.ScheduleRunTypeDaily): - schedule.DailySchedule = &backup.DailySchedule{ + case string(protectionpolicies.ScheduleRunTypeDaily): + schedule.DailySchedule = &protectionpolicies.DailySchedule{ ScheduleRunTimes: ×, } - case string(backup.ScheduleRunTypeWeekly): + case string(protectionpolicies.ScheduleRunTypeWeekly): weekDays, ok := block["weekdays"].(*pluginsdk.Set) if !ok { return nil, fmt.Errorf("`weekdays` must be specified when `backup.0.frequency` is `Weekly`") } - days := make([]backup.DayOfWeek, 0) + days := make([]protectionpolicies.DayOfWeek, 0) for _, day := range weekDays.List() { - days = append(days, backup.DayOfWeek(day.(string))) + days = append(days, protectionpolicies.DayOfWeek(day.(string))) } - schedule.WeeklySchedule = &backup.WeeklySchedule{ + schedule.WeeklySchedule = &protectionpolicies.WeeklySchedule{ ScheduleRunDays: &days, ScheduleRunTimes: ×, } @@ -401,18 +380,17 @@ func expandBackupProtectionPolicyVMSchedule(d *pluginsdk.ResourceData, times []d return nil, fmt.Errorf("Unrecognized value for backup.0.frequency") } - result, _ := schedule.AsBasicSchedulePolicy() - return &result, nil + return schedule, nil } } return nil, nil } -func expandBackupProtectionPolicyVMResourceGroup(d *pluginsdk.ResourceData) *backup.InstantRPAdditionalDetails { +func expandBackupProtectionPolicyVMResourceGroup(d *pluginsdk.ResourceData) *protectionpolicies.InstantRPAdditionalDetails { if v, ok := d.Get("instant_restore_resource_group").([]interface{}); ok && len(v) > 0 { rgRaw := v[0].(map[string]interface{}) - output := &backup.InstantRPAdditionalDetails{ + output := &protectionpolicies.InstantRPAdditionalDetails{ AzureBackupRGNamePrefix: utils.String(rgRaw["prefix"].(string)), } if suffix, ok := rgRaw["suffix"]; ok && suffix != "" { @@ -424,15 +402,15 @@ func expandBackupProtectionPolicyVMResourceGroup(d *pluginsdk.ResourceData) *bac return nil } -func expandBackupProtectionPolicyVMRetentionDaily(d *pluginsdk.ResourceData, times []date.Time) *backup.DailyRetentionSchedule { +func expandBackupProtectionPolicyVMRetentionDaily(d *pluginsdk.ResourceData, times []string) *protectionpolicies.DailyRetentionSchedule { if rb, ok := d.Get("retention_daily").([]interface{}); ok && len(rb) > 0 { block := rb[0].(map[string]interface{}) - return &backup.DailyRetentionSchedule{ + return &protectionpolicies.DailyRetentionSchedule{ RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(int32(block["count"].(int))), - DurationType: backup.RetentionDurationTypeDays, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(int64(block["count"].(int))), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeDays), }, } } @@ -440,22 +418,22 @@ func expandBackupProtectionPolicyVMRetentionDaily(d *pluginsdk.ResourceData, tim return nil } -func expandBackupProtectionPolicyVMRetentionWeekly(d *pluginsdk.ResourceData, times []date.Time) *backup.WeeklyRetentionSchedule { +func expandBackupProtectionPolicyVMRetentionWeekly(d *pluginsdk.ResourceData, times []string) *protectionpolicies.WeeklyRetentionSchedule { if rb, ok := d.Get("retention_weekly").([]interface{}); ok && len(rb) > 0 { block := rb[0].(map[string]interface{}) - retention := backup.WeeklyRetentionSchedule{ + retention := protectionpolicies.WeeklyRetentionSchedule{ RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(int32(block["count"].(int))), - DurationType: backup.RetentionDurationTypeWeeks, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(int64(block["count"].(int))), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeWeeks), }, } if v, ok := block["weekdays"].(*pluginsdk.Set); ok { - days := make([]backup.DayOfWeek, 0) + days := make([]protectionpolicies.DayOfWeek, 0) for _, day := range v.List() { - days = append(days, backup.DayOfWeek(day.(string))) + days = append(days, protectionpolicies.DayOfWeek(day.(string))) } retention.DaysOfTheWeek = &days } @@ -466,18 +444,18 @@ func expandBackupProtectionPolicyVMRetentionWeekly(d *pluginsdk.ResourceData, ti return nil } -func expandBackupProtectionPolicyVMRetentionMonthly(d *pluginsdk.ResourceData, times []date.Time) *backup.MonthlyRetentionSchedule { +func expandBackupProtectionPolicyVMRetentionMonthly(d *pluginsdk.ResourceData, times []string) *protectionpolicies.MonthlyRetentionSchedule { if rb, ok := d.Get("retention_monthly").([]interface{}); ok && len(rb) > 0 { block := rb[0].(map[string]interface{}) - retention := backup.MonthlyRetentionSchedule{ - RetentionScheduleFormatType: backup.RetentionScheduleFormatWeekly, // this is always weekly ¯\_(ツ)_/¯ - RetentionScheduleDaily: nil, // and this is always nil.. + retention := protectionpolicies.MonthlyRetentionSchedule{ + RetentionScheduleFormatType: pointer.To(protectionpolicies.RetentionScheduleFormatWeekly), // this is always weekly ¯\_(ツ)_/¯ + RetentionScheduleDaily: nil, // and this is always nil.. RetentionScheduleWeekly: expandBackupProtectionPolicyVMRetentionWeeklyFormat(block), RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(int32(block["count"].(int))), - DurationType: backup.RetentionDurationTypeMonths, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(int64(block["count"].(int))), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeMonths), }, } @@ -487,25 +465,25 @@ func expandBackupProtectionPolicyVMRetentionMonthly(d *pluginsdk.ResourceData, t return nil } -func expandBackupProtectionPolicyVMRetentionYearly(d *pluginsdk.ResourceData, times []date.Time) *backup.YearlyRetentionSchedule { +func expandBackupProtectionPolicyVMRetentionYearly(d *pluginsdk.ResourceData, times []string) *protectionpolicies.YearlyRetentionSchedule { if rb, ok := d.Get("retention_yearly").([]interface{}); ok && len(rb) > 0 { block := rb[0].(map[string]interface{}) - retention := backup.YearlyRetentionSchedule{ - RetentionScheduleFormatType: backup.RetentionScheduleFormatWeekly, // this is always weekly ¯\_(ツ)_/¯ - RetentionScheduleDaily: nil, // and this is always nil.. + retention := protectionpolicies.YearlyRetentionSchedule{ + RetentionScheduleFormatType: pointer.To(protectionpolicies.RetentionScheduleFormatWeekly), // this is always weekly ¯\_(ツ)_/¯ + RetentionScheduleDaily: nil, // and this is always nil.. RetentionScheduleWeekly: expandBackupProtectionPolicyVMRetentionWeeklyFormat(block), RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(int32(block["count"].(int))), - DurationType: backup.RetentionDurationTypeYears, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(int64(block["count"].(int))), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeYears), }, } if v, ok := block["months"].(*pluginsdk.Set); ok { - months := make([]backup.MonthOfYear, 0) + months := make([]protectionpolicies.MonthOfYear, 0) for _, month := range v.List() { - months = append(months, backup.MonthOfYear(month.(string))) + months = append(months, protectionpolicies.MonthOfYear(month.(string))) } retention.MonthsOfYear = &months } @@ -516,21 +494,21 @@ func expandBackupProtectionPolicyVMRetentionYearly(d *pluginsdk.ResourceData, ti return nil } -func expandBackupProtectionPolicyVMRetentionWeeklyFormat(block map[string]interface{}) *backup.WeeklyRetentionFormat { - weekly := backup.WeeklyRetentionFormat{} +func expandBackupProtectionPolicyVMRetentionWeeklyFormat(block map[string]interface{}) *protectionpolicies.WeeklyRetentionFormat { + weekly := protectionpolicies.WeeklyRetentionFormat{} if v, ok := block["weekdays"].(*pluginsdk.Set); ok { - days := make([]backup.DayOfWeek, 0) + days := make([]protectionpolicies.DayOfWeek, 0) for _, day := range v.List() { - days = append(days, backup.DayOfWeek(day.(string))) + days = append(days, protectionpolicies.DayOfWeek(day.(string))) } weekly.DaysOfTheWeek = &days } if v, ok := block["weeks"].(*pluginsdk.Set); ok { - weeks := make([]backup.WeekOfMonth, 0) + weeks := make([]protectionpolicies.WeekOfMonth, 0) for _, week := range v.List() { - weeks = append(weeks, backup.WeekOfMonth(week.(string))) + weeks = append(weeks, protectionpolicies.WeekOfMonth(week.(string))) } weekly.WeeksOfTheMonth = &weeks } @@ -538,7 +516,7 @@ func expandBackupProtectionPolicyVMRetentionWeeklyFormat(block map[string]interf return &weekly } -func flattenBackupProtectionPolicyVMResourceGroup(rpDetail backup.InstantRPAdditionalDetails) []interface{} { +func flattenBackupProtectionPolicyVMResourceGroup(rpDetail protectionpolicies.InstantRPAdditionalDetails) []interface{} { if rpDetail.AzureBackupRGNamePrefix == nil { return nil } @@ -560,13 +538,13 @@ func flattenBackupProtectionPolicyVMResourceGroup(rpDetail backup.InstantRPAddit return []interface{}{block} } -func flattenBackupProtectionPolicyVMSchedule(schedule *backup.SimpleSchedulePolicy) []interface{} { +func flattenBackupProtectionPolicyVMSchedule(schedule protectionpolicies.SimpleSchedulePolicy) []interface{} { block := map[string]interface{}{} - block["frequency"] = string(schedule.ScheduleRunFrequency) + block["frequency"] = string(pointer.From(schedule.ScheduleRunFrequency)) if times := schedule.ScheduleRunTimes; times != nil && len(*times) > 0 { - block["time"] = (*times)[0].Format("15:04") + block["time"] = (*times)[0] } if days := schedule.ScheduleRunDays; days != nil { @@ -580,14 +558,14 @@ func flattenBackupProtectionPolicyVMSchedule(schedule *backup.SimpleSchedulePoli return []interface{}{block} } -func flattenBackupProtectionPolicyVMScheduleV2(schedule *backup.SimpleSchedulePolicyV2) []interface{} { +func flattenBackupProtectionPolicyVMScheduleV2(schedule protectionpolicies.SimpleSchedulePolicyV2) []interface{} { block := map[string]interface{}{} - frequency := schedule.ScheduleRunFrequency + frequency := pointer.From(schedule.ScheduleRunFrequency) block["frequency"] = string(frequency) switch frequency { - case backup.ScheduleRunTypeHourly: + case protectionpolicies.ScheduleRunTypeHourly: schedule := schedule.HourlySchedule if schedule.Interval != nil { block["hour_interval"] = *schedule.Interval @@ -598,14 +576,14 @@ func flattenBackupProtectionPolicyVMScheduleV2(schedule *backup.SimpleSchedulePo } if schedule.ScheduleWindowStartTime != nil { - block["time"] = schedule.ScheduleWindowStartTime.Format("15:04") + block["time"] = schedule.ScheduleWindowStartTime } - case backup.ScheduleRunTypeDaily: + case protectionpolicies.ScheduleRunTypeDaily: schedule := schedule.DailySchedule if times := schedule.ScheduleRunTimes; times != nil && len(*times) > 0 { - block["time"] = (*times)[0].Format("15:04") + block["time"] = (*times)[0] } - case backup.ScheduleRunTypeWeekly: + case protectionpolicies.ScheduleRunTypeWeekly: schedule := schedule.WeeklySchedule if days := schedule.ScheduleRunDays; days != nil { weekdays := make([]interface{}, 0) @@ -616,7 +594,7 @@ func flattenBackupProtectionPolicyVMScheduleV2(schedule *backup.SimpleSchedulePo } if times := schedule.ScheduleRunTimes; times != nil && len(*times) > 0 { - block["time"] = (*times)[0].Format("15:04") + block["time"] = (*times)[0] } default: } @@ -624,7 +602,7 @@ func flattenBackupProtectionPolicyVMScheduleV2(schedule *backup.SimpleSchedulePo return []interface{}{block} } -func flattenBackupProtectionPolicyVMRetentionDaily(daily *backup.DailyRetentionSchedule) []interface{} { +func flattenBackupProtectionPolicyVMRetentionDaily(daily *protectionpolicies.DailyRetentionSchedule) []interface{} { block := map[string]interface{}{} if duration := daily.RetentionDuration; duration != nil { @@ -636,7 +614,7 @@ func flattenBackupProtectionPolicyVMRetentionDaily(daily *backup.DailyRetentionS return []interface{}{block} } -func flattenBackupProtectionPolicyVMRetentionWeekly(weekly *backup.WeeklyRetentionSchedule) []interface{} { +func flattenBackupProtectionPolicyVMRetentionWeekly(weekly *protectionpolicies.WeeklyRetentionSchedule) []interface{} { block := map[string]interface{}{} if duration := weekly.RetentionDuration; duration != nil { @@ -656,7 +634,7 @@ func flattenBackupProtectionPolicyVMRetentionWeekly(weekly *backup.WeeklyRetenti return []interface{}{block} } -func flattenBackupProtectionPolicyVMRetentionMonthly(monthly *backup.MonthlyRetentionSchedule) []interface{} { +func flattenBackupProtectionPolicyVMRetentionMonthly(monthly *protectionpolicies.MonthlyRetentionSchedule) []interface{} { block := map[string]interface{}{} if duration := monthly.RetentionDuration; duration != nil { @@ -672,7 +650,7 @@ func flattenBackupProtectionPolicyVMRetentionMonthly(monthly *backup.MonthlyRete return []interface{}{block} } -func flattenBackupProtectionPolicyVMRetentionYearly(yearly *backup.YearlyRetentionSchedule) []interface{} { +func flattenBackupProtectionPolicyVMRetentionYearly(yearly *protectionpolicies.YearlyRetentionSchedule) []interface{} { block := map[string]interface{}{} if duration := yearly.RetentionDuration; duration != nil { @@ -696,7 +674,7 @@ func flattenBackupProtectionPolicyVMRetentionYearly(yearly *backup.YearlyRetenti return []interface{}{block} } -func flattenBackupProtectionPolicyVMRetentionWeeklyFormat(retention *backup.WeeklyRetentionFormat) (weekdays, weeks *pluginsdk.Set) { +func flattenBackupProtectionPolicyVMRetentionWeeklyFormat(retention *protectionpolicies.WeeklyRetentionFormat) (weekdays, weeks *pluginsdk.Set) { if days := retention.DaysOfTheWeek; days != nil { slice := make([]interface{}, 0) for _, d := range *days { @@ -716,13 +694,13 @@ func flattenBackupProtectionPolicyVMRetentionWeeklyFormat(retention *backup.Week return weekdays, weeks } -func resourceBackupProtectionPolicyVMWaitForUpdate(ctx context.Context, client *backup.ProtectionPoliciesClient, vaultName, resourceGroup, policyName string, d *pluginsdk.ResourceData) (backup.ProtectionPolicyResource, error) { +func resourceBackupProtectionPolicyVMWaitForUpdate(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) (protectionpolicies.ProtectionPolicyResource, error) { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, Pending: []string{"NotFound"}, Target: []string{"Found"}, - Refresh: resourceBackupProtectionPolicyVMRefreshFunc(ctx, client, vaultName, resourceGroup, policyName), + Refresh: resourceBackupProtectionPolicyVMRefreshFunc(ctx, client, id), } if d.IsNewResource() { @@ -733,39 +711,39 @@ func resourceBackupProtectionPolicyVMWaitForUpdate(ctx context.Context, client * resp, err := state.WaitForStateContext(ctx) if err != nil { - return resp.(backup.ProtectionPolicyResource), fmt.Errorf("waiting for the Azure Backup Protection Policy %q to be true (Resource Group %q) to provision: %+v", policyName, resourceGroup, err) + return resp.(protectionpolicies.ProtectionPolicyResource), fmt.Errorf("waiting for %s to provision: %+v", id, err) } - return resp.(backup.ProtectionPolicyResource), nil + return resp.(protectionpolicies.ProtectionPolicyResource), nil } -func resourceBackupProtectionPolicyVMWaitForDeletion(ctx context.Context, client *backup.ProtectionPoliciesClient, vaultName, resourceGroup, policyName string, d *pluginsdk.ResourceData) (backup.ProtectionPolicyResource, error) { +func resourceBackupProtectionPolicyVMWaitForDeletion(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) (protectionpolicies.ProtectionPolicyResource, error) { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, Pending: []string{"Found"}, Target: []string{"NotFound"}, - Refresh: resourceBackupProtectionPolicyVMRefreshFunc(ctx, client, vaultName, resourceGroup, policyName), + Refresh: resourceBackupProtectionPolicyVMRefreshFunc(ctx, client, id), Timeout: d.Timeout(pluginsdk.TimeoutDelete), } resp, err := state.WaitForStateContext(ctx) if err != nil { - return resp.(backup.ProtectionPolicyResource), fmt.Errorf("waiting for the Azure Backup Protection Policy %q to be false (Resource Group %q) to provision: %+v", policyName, resourceGroup, err) + return resp.(protectionpolicies.ProtectionPolicyResource), fmt.Errorf("waiting for %s to provision: %+v", id, err) } - return resp.(backup.ProtectionPolicyResource), nil + return resp.(protectionpolicies.ProtectionPolicyResource), nil } -func resourceBackupProtectionPolicyVMRefreshFunc(ctx context.Context, client *backup.ProtectionPoliciesClient, vaultName, resourceGroup, policyName string) pluginsdk.StateRefreshFunc { +func resourceBackupProtectionPolicyVMRefreshFunc(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId) pluginsdk.StateRefreshFunc { return func() (interface{}, string, error) { - resp, err := client.Get(ctx, vaultName, resourceGroup, policyName) + resp, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return resp, "NotFound", nil } - return resp, "Error", fmt.Errorf("making Read request on Azure Backup Protection Policy %q (Resource Group %q): %+v", policyName, resourceGroup, err) + return resp, "Error", fmt.Errorf("making Read request on %s: %+v", id, err) } return resp, "Found", nil @@ -836,9 +814,9 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(backup.ScheduleRunTypeHourly), - string(backup.ScheduleRunTypeDaily), - string(backup.ScheduleRunTypeWeekly), + string(protectionpolicies.ScheduleRunTypeHourly), + string(protectionpolicies.ScheduleRunTypeDaily), + string(protectionpolicies.ScheduleRunTypeWeekly), }, false), }, @@ -886,10 +864,10 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Optional: true, ForceNew: true, - Default: string(backup.IAASVMPolicyTypeV1), + Default: string(protectionpolicies.IAASVMPolicyTypeVOne), ValidateFunc: validation.StringInSlice([]string{ - string(backup.IAASVMPolicyTypeV1), - string(backup.IAASVMPolicyTypeV2), + string(protectionpolicies.IAASVMPolicyTypeVOne), + string(protectionpolicies.IAASVMPolicyTypeVTwo), }, false), }, @@ -954,11 +932,11 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, ValidateFunc: validation.StringInSlice([]string{ - string(backup.WeekOfMonthFirst), - string(backup.WeekOfMonthSecond), - string(backup.WeekOfMonthThird), - string(backup.WeekOfMonthFourth), - string(backup.WeekOfMonthLast), + string(protectionpolicies.WeekOfMonthFirst), + string(protectionpolicies.WeekOfMonthSecond), + string(protectionpolicies.WeekOfMonthThird), + string(protectionpolicies.WeekOfMonthFourth), + string(protectionpolicies.WeekOfMonthLast), }, false), }, }, @@ -1007,11 +985,11 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, ValidateFunc: validation.StringInSlice([]string{ - string(backup.WeekOfMonthFirst), - string(backup.WeekOfMonthSecond), - string(backup.WeekOfMonthThird), - string(backup.WeekOfMonthFourth), - string(backup.WeekOfMonthLast), + string(protectionpolicies.WeekOfMonthFirst), + string(protectionpolicies.WeekOfMonthSecond), + string(protectionpolicies.WeekOfMonthThird), + string(protectionpolicies.WeekOfMonthFourth), + string(protectionpolicies.WeekOfMonthLast), }, false), }, }, diff --git a/internal/services/recoveryservices/backup_policy_vm_resource_test.go b/internal/services/recoveryservices/backup_policy_vm_resource_test.go index 44177516f597..2a995349f6bb 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource_test.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -546,17 +546,17 @@ func TestAccBackupProtectionPolicyVM_withCustomRGName(t *testing.T) { } func (t BackupProtectionPolicyVMResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.BackupPolicyID(state.ID) + id, err := protectionpolicies.ParseBackupPolicyID(state.ID) if err != nil { return nil, err } - resp, err := clients.RecoveryServices.ProtectionPoliciesClient.Get(ctx, id.VaultName, id.ResourceGroup, id.Name) + resp, err := clients.RecoveryServices.ProtectionPoliciesClient.Get(ctx, *id) if err != nil { return nil, fmt.Errorf("reading Recovery Service Protection Policy (%s): %+v", id.String(), err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (BackupProtectionPolicyVMResource) template(data acceptance.TestData) string { diff --git a/internal/services/recoveryservices/backup_policy_vm_workload_resource.go b/internal/services/recoveryservices/backup_policy_vm_workload_resource.go index 231dad90836f..77f63f2c9d59 100644 --- a/internal/services/recoveryservices/backup_policy_vm_workload_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_workload_resource.go @@ -6,12 +6,13 @@ import ( "regexp" "time" - "github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup" // nolint: staticcheck "github.com/Azure/go-autorest/autorest/date" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/set" @@ -41,22 +42,22 @@ type ProtectionPolicy struct { type Backup struct { Frequency string `tfschema:"frequency"` - FrequencyInMinutes int32 `tfschema:"frequency_in_minutes"` + FrequencyInMinutes int64 `tfschema:"frequency_in_minutes"` Time string `tfschema:"time"` Weekdays []string `tfschema:"weekdays"` } type RetentionDaily struct { - Count int32 `tfschema:"count"` + Count int64 `tfschema:"count"` } type RetentionWeekly struct { - Count int32 `tfschema:"count"` + Count int64 `tfschema:"count"` Weekdays []string `tfschema:"weekdays"` } type RetentionMonthly struct { - Count int32 `tfschema:"count"` + Count int64 `tfschema:"count"` FormatType string `tfschema:"format_type"` Monthdays []int `tfschema:"monthdays"` Weeks []string `tfschema:"weeks"` @@ -64,7 +65,7 @@ type RetentionMonthly struct { } type RetentionYearly struct { - Count int32 `tfschema:"count"` + Count int64 `tfschema:"count"` FormatType string `tfschema:"format_type"` Months []string `tfschema:"months"` Monthdays []int `tfschema:"monthdays"` @@ -73,7 +74,7 @@ type RetentionYearly struct { } type SimpleRetention struct { - Count int32 `tfschema:"count"` + Count int64 `tfschema:"count"` } type Settings struct { @@ -94,7 +95,7 @@ func (r BackupProtectionPolicyVMWorkloadResource) ModelObject() interface{} { } func (r BackupProtectionPolicyVMWorkloadResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { - return validate.BackupPolicyID + return protectionpolicies.ValidateBackupPolicyID } func (r BackupProtectionPolicyVMWorkloadResource) Arguments() map[string]*pluginsdk.Schema { @@ -124,10 +125,10 @@ func (r BackupProtectionPolicyVMWorkloadResource) Arguments() map[string]*plugin Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(backup.PolicyTypeDifferential), - string(backup.PolicyTypeFull), - string(backup.PolicyTypeIncremental), - string(backup.PolicyTypeLog), + string(protectionpolicies.PolicyTypeDifferential), + string(protectionpolicies.PolicyTypeFull), + string(protectionpolicies.PolicyTypeIncremental), + string(protectionpolicies.PolicyTypeLog), }, false), }, @@ -141,8 +142,8 @@ func (r BackupProtectionPolicyVMWorkloadResource) Arguments() map[string]*plugin Type: pluginsdk.TypeString, Optional: true, ValidateFunc: validation.StringInSlice([]string{ - string(backup.ScheduleRunTypeDaily), - string(backup.ScheduleRunTypeWeekly), + string(protectionpolicies.ScheduleRunTypeDaily), + string(protectionpolicies.ScheduleRunTypeWeekly), }, false), }, @@ -241,8 +242,8 @@ func (r BackupProtectionPolicyVMWorkloadResource) Arguments() map[string]*plugin Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(backup.RetentionScheduleFormatDaily), - string(backup.RetentionScheduleFormatWeekly), + string(protectionpolicies.RetentionScheduleFormatDaily), + string(protectionpolicies.RetentionScheduleFormatWeekly), }, false), }, @@ -262,11 +263,11 @@ func (r BackupProtectionPolicyVMWorkloadResource) Arguments() map[string]*plugin Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, ValidateFunc: validation.StringInSlice([]string{ - string(backup.WeekOfMonthFirst), - string(backup.WeekOfMonthSecond), - string(backup.WeekOfMonthThird), - string(backup.WeekOfMonthFourth), - string(backup.WeekOfMonthLast), + string(protectionpolicies.WeekOfMonthFirst), + string(protectionpolicies.WeekOfMonthSecond), + string(protectionpolicies.WeekOfMonthThird), + string(protectionpolicies.WeekOfMonthFourth), + string(protectionpolicies.WeekOfMonthLast), }, false), }, }, @@ -301,8 +302,8 @@ func (r BackupProtectionPolicyVMWorkloadResource) Arguments() map[string]*plugin Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(backup.RetentionScheduleFormatDaily), - string(backup.RetentionScheduleFormatWeekly), + string(protectionpolicies.RetentionScheduleFormatDaily), + string(protectionpolicies.RetentionScheduleFormatWeekly), }, false), }, @@ -333,11 +334,11 @@ func (r BackupProtectionPolicyVMWorkloadResource) Arguments() map[string]*plugin Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, ValidateFunc: validation.StringInSlice([]string{ - string(backup.WeekOfMonthFirst), - string(backup.WeekOfMonthSecond), - string(backup.WeekOfMonthThird), - string(backup.WeekOfMonthFourth), - string(backup.WeekOfMonthLast), + string(protectionpolicies.WeekOfMonthFirst), + string(protectionpolicies.WeekOfMonthSecond), + string(protectionpolicies.WeekOfMonthThird), + string(protectionpolicies.WeekOfMonthFourth), + string(protectionpolicies.WeekOfMonthLast), }, false), }, }, @@ -400,8 +401,8 @@ func (r BackupProtectionPolicyVMWorkloadResource) Arguments() map[string]*plugin Required: true, ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ - string(backup.WorkloadTypeSQLDataBase), - string(backup.WorkloadTypeSAPHanaDatabase), + string(protectionpolicies.WorkloadTypeSQLDataBase), + string(protectionpolicies.WorkloadTypeSAPHanaDatabase), }, false), }, } @@ -423,15 +424,15 @@ func (r BackupProtectionPolicyVMWorkloadResource) Create() sdk.ResourceFunc { client := metadata.Client.RecoveryServices.ProtectionPoliciesClient subscriptionId := metadata.Client.Account.SubscriptionId - id := parse.NewBackupPolicyID(subscriptionId, model.ResourceGroupName, model.RecoveryVaultName, model.Name) + id := protectionpolicies.NewBackupPolicyID(subscriptionId, model.ResourceGroupName, model.RecoveryVaultName, model.Name) - existing, err := client.Get(ctx, id.VaultName, id.ResourceGroup, id.Name) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_backup_policy_vm_workload", id.ID()) } @@ -440,16 +441,15 @@ func (r BackupProtectionPolicyVMWorkloadResource) Create() sdk.ResourceFunc { return err } - properties := &backup.ProtectionPolicyResource{ - Properties: &backup.AzureVMWorkloadProtectionPolicy{ - BackupManagementType: backup.ManagementTypeBasicProtectionPolicyBackupManagementTypeAzureWorkload, - Settings: expandBackupProtectionPolicyVMWorkloadSettings(model.Settings), - SubProtectionPolicy: protectionPolicy, - WorkLoadType: backup.WorkloadType(model.WorkloadType), + properties := &protectionpolicies.ProtectionPolicyResource{ + Properties: &protectionpolicies.AzureVMWorkloadProtectionPolicy{ + Settings: expandBackupProtectionPolicyVMWorkloadSettings(model.Settings), + SubProtectionPolicy: protectionPolicy, + WorkLoadType: pointer.To(protectionpolicies.WorkloadType(model.WorkloadType)), }, } - if _, err := client.CreateOrUpdate(ctx, id.VaultName, id.ResourceGroup, id.Name, *properties); err != nil { + if _, err := client.CreateOrUpdate(ctx, id, *properties); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } @@ -465,7 +465,7 @@ func (r BackupProtectionPolicyVMWorkloadResource) Update() sdk.ResourceFunc { Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.RecoveryServices.ProtectionPoliciesClient - id, err := parse.BackupPolicyID(metadata.ResourceData.Id()) + id, err := protectionpolicies.ParseBackupPolicyID(metadata.ResourceData.Id()) if err != nil { return err } @@ -475,30 +475,32 @@ func (r BackupProtectionPolicyVMWorkloadResource) Update() sdk.ResourceFunc { return fmt.Errorf("decoding: %+v", err) } - existing, err := client.Get(ctx, id.VaultName, id.ResourceGroup, id.Name) + existing, err := client.Get(ctx, *id) if err != nil { return fmt.Errorf("retrieving %s: %+v", *id, err) } - props, _ := existing.Properties.AsAzureVMWorkloadProtectionPolicy() + if m := existing.Model; m != nil { + props, _ := m.Properties.(protectionpolicies.AzureVMWorkloadProtectionPolicy) - if metadata.ResourceData.HasChange("settings") { - props.Settings = expandBackupProtectionPolicyVMWorkloadSettings(model.Settings) - } - - if metadata.ResourceData.HasChange("protection_policy") { - protectionPolicy, err := expandBackupProtectionPolicyVMWorkloadProtectionPolicies(model.ProtectionPolicies, model.WorkloadType) - if err != nil { - return err + if metadata.ResourceData.HasChange("settings") { + props.Settings = expandBackupProtectionPolicyVMWorkloadSettings(model.Settings) } - props.SubProtectionPolicy = protectionPolicy - } + if metadata.ResourceData.HasChange("protection_policy") { + protectionPolicy, err := expandBackupProtectionPolicyVMWorkloadProtectionPolicies(model.ProtectionPolicies, model.WorkloadType) + if err != nil { + return err + } + + props.SubProtectionPolicy = protectionPolicy + } - existing.Properties = props + m.Properties = props - if _, err := client.CreateOrUpdate(ctx, id.VaultName, id.ResourceGroup, id.Name, existing); err != nil { - return fmt.Errorf("updating %s: %+v", *id, err) + if _, err := client.CreateOrUpdate(ctx, *id, *m); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } } return nil @@ -512,14 +514,14 @@ func (r BackupProtectionPolicyVMWorkloadResource) Read() sdk.ResourceFunc { Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.RecoveryServices.ProtectionPoliciesClient - id, err := parse.BackupPolicyID(metadata.ResourceData.Id()) + id, err := protectionpolicies.ParseBackupPolicyID(metadata.ResourceData.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.VaultName, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return metadata.MarkAsGone(id) } @@ -527,16 +529,18 @@ func (r BackupProtectionPolicyVMWorkloadResource) Read() sdk.ResourceFunc { } state := BackupProtectionPolicyVMWorkloadModel{ - Name: id.Name, - ResourceGroupName: id.ResourceGroup, + Name: id.BackupPolicyName, + ResourceGroupName: id.ResourceGroupName, RecoveryVaultName: id.VaultName, } - if props := resp.Properties; props != nil { - vmWorkload, _ := props.AsAzureVMWorkloadProtectionPolicy() - state.WorkloadType = string(vmWorkload.WorkLoadType) - state.Settings = flattenBackupProtectionPolicyVMWorkloadSettings(vmWorkload.Settings) - state.ProtectionPolicies = flattenBackupProtectionPolicyVMWorkloadProtectionPolicies(vmWorkload.SubProtectionPolicy) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + vmWorkload, _ := props.(protectionpolicies.AzureVMWorkloadProtectionPolicy) + state.WorkloadType = string(pointer.From(vmWorkload.WorkLoadType)) + state.Settings = flattenBackupProtectionPolicyVMWorkloadSettings(vmWorkload.Settings) + state.ProtectionPolicies = flattenBackupProtectionPolicyVMWorkloadProtectionPolicies(vmWorkload.SubProtectionPolicy) + } } return metadata.Encode(&state) @@ -550,32 +554,27 @@ func (r BackupProtectionPolicyVMWorkloadResource) Delete() sdk.ResourceFunc { Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.RecoveryServices.ProtectionPoliciesClient - id, err := parse.BackupPolicyID(metadata.ResourceData.Id()) + id, err := protectionpolicies.ParseBackupPolicyID(metadata.ResourceData.Id()) if err != nil { return err } - future, err := client.Delete(ctx, id.VaultName, id.ResourceGroup, id.Name) - if err != nil { + if err := client.DeleteThenPoll(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", *id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for the deletion of %s: %+v", *id, err) - } - return nil }, } } -func expandBackupProtectionPolicyVMWorkloadSettings(input []Settings) *backup.Settings { +func expandBackupProtectionPolicyVMWorkloadSettings(input []Settings) *protectionpolicies.Settings { if len(input) == 0 { - return &backup.Settings{} + return &protectionpolicies.Settings{} } settings := input[0] - result := &backup.Settings{ + result := &protectionpolicies.Settings{ IsCompression: utils.Bool(settings.CompressionEnabled), } @@ -586,7 +585,7 @@ func expandBackupProtectionPolicyVMWorkloadSettings(input []Settings) *backup.Se return result } -func flattenBackupProtectionPolicyVMWorkloadSettings(input *backup.Settings) []Settings { +func flattenBackupProtectionPolicyVMWorkloadSettings(input *protectionpolicies.Settings) []Settings { if input == nil { return make([]Settings, 0) } @@ -601,15 +600,15 @@ func flattenBackupProtectionPolicyVMWorkloadSettings(input *backup.Settings) []S return result } -func expandBackupProtectionPolicyVMWorkloadProtectionPolicies(input []ProtectionPolicy, workloadType string) (*[]backup.SubProtectionPolicy, error) { +func expandBackupProtectionPolicyVMWorkloadProtectionPolicies(input []ProtectionPolicy, workloadType string) (*[]protectionpolicies.SubProtectionPolicy, error) { if len(input) == 0 { return nil, nil } - results := make([]backup.SubProtectionPolicy, 0) + results := make([]protectionpolicies.SubProtectionPolicy, 0) for _, item := range input { - if workloadType == string(backup.WorkloadTypeSQLDataBase) && item.PolicyType == string(backup.PolicyTypeIncremental) { + if workloadType == string(protectionpolicies.WorkloadTypeSQLDataBase) && item.PolicyType == string(protectionpolicies.PolicyTypeIncremental) { return nil, fmt.Errorf("the Incremental backup isn't supported when `workload_type` is `SQLDataBase`") } @@ -617,17 +616,17 @@ func expandBackupProtectionPolicyVMWorkloadProtectionPolicies(input []Protection // getting this ready now because its shared between *everything*, time is... complicated for this resource timeOfDay := backupBlock.Time - times := make([]date.Time, 0) + times := make([]string, 0) if timeOfDay != "" { dateOfDay, err := time.Parse(time.RFC3339, fmt.Sprintf("2018-07-30T%s:00Z", timeOfDay)) if err != nil { return nil, fmt.Errorf("generating time from %q for policy): %+v", timeOfDay, err) } - times = append(times, date.Time{Time: dateOfDay}) + times = append(times, date.Time{Time: dateOfDay}.String()) } switch backupBlock.Frequency { - case string(backup.ScheduleRunTypeDaily): + case string(protectionpolicies.ScheduleRunTypeDaily): if item.RetentionDaily == nil || len(item.RetentionDaily) == 0 { return nil, fmt.Errorf("`retention_daily` must be set when `backup.0.frequency` is `Daily`") } @@ -635,22 +634,22 @@ func expandBackupProtectionPolicyVMWorkloadProtectionPolicies(input []Protection if weekdays := backupBlock.Weekdays; len(weekdays) > 0 { return nil, fmt.Errorf("`backup.0.weekdays` should be not set when `backup.0.frequency` is `Daily`") } - case string(backup.ScheduleRunTypeWeekly): + case string(protectionpolicies.ScheduleRunTypeWeekly): if len(item.RetentionDaily) > 0 { return nil, fmt.Errorf("`retention_daily` must be not set when `backup.0.frequency` is `Weekly`") } - if item.PolicyType != string(backup.PolicyTypeLog) && len(backupBlock.Weekdays) == 0 { + if item.PolicyType != string(protectionpolicies.PolicyTypeLog) && len(backupBlock.Weekdays) == 0 { return nil, fmt.Errorf("`backup.weekdays` must be set when `policy_type` is not `Log` and `backup.frequency` is `Weekly`") } - if item.PolicyType == string(backup.PolicyTypeFull) && len(item.RetentionWeekly) == 0 { + if item.PolicyType == string(protectionpolicies.PolicyTypeFull) && len(item.RetentionWeekly) == 0 { return nil, fmt.Errorf("`retention_weekly` must be set when `policy_type` is `Full` and `backup.frequency` is `Weekly`") } } - result := backup.SubProtectionPolicy{ - PolicyType: backup.PolicyType(item.PolicyType), + result := protectionpolicies.SubProtectionPolicy{ + PolicyType: pointer.To(protectionpolicies.PolicyType(item.PolicyType)), SchedulePolicy: expandBackupProtectionPolicyVMWorkloadSchedulePolicy(item, times), } @@ -666,31 +665,26 @@ func expandBackupProtectionPolicyVMWorkloadProtectionPolicies(input []Protection return &results, nil } -func flattenBackupProtectionPolicyVMWorkloadProtectionPolicies(input *[]backup.SubProtectionPolicy) []ProtectionPolicy { +func flattenBackupProtectionPolicyVMWorkloadProtectionPolicies(input *[]protectionpolicies.SubProtectionPolicy) []ProtectionPolicy { results := make([]ProtectionPolicy, 0) if input == nil { return results } for _, item := range *input { - var policyType backup.PolicyType - if item.PolicyType != "" { - policyType = item.PolicyType - } - result := ProtectionPolicy{ - PolicyType: string(policyType), - Backup: flattenBackupProtectionPolicyVMWorkloadSchedulePolicy(item.SchedulePolicy, policyType), + PolicyType: string(pointer.From(item.PolicyType)), + Backup: flattenBackupProtectionPolicyVMWorkloadSchedulePolicy(item.SchedulePolicy, pointer.From(item.PolicyType)), } if retentionPolicy := item.RetentionPolicy; retentionPolicy != nil { - if longTermRetentionPolicy, ok := retentionPolicy.AsLongTermRetentionPolicy(); ok { + if longTermRetentionPolicy, ok := retentionPolicy.(protectionpolicies.LongTermRetentionPolicy); ok { result.RetentionDaily = flattenBackupProtectionPolicyVMWorkloadRetentionDaily(longTermRetentionPolicy.DailySchedule) result.RetentionWeekly = flattenBackupProtectionPolicyVMWorkloadRetentionWeekly(longTermRetentionPolicy.WeeklySchedule) result.RetentionMonthly = flattenBackupProtectionPolicyVMWorkloadRetentionMonthly(longTermRetentionPolicy.MonthlySchedule) result.RetentionYearly = flattenBackupProtectionPolicyVMWorkloadRetentionYearly(longTermRetentionPolicy.YearlySchedule) } else { - simpleRetentionPolicy, _ := retentionPolicy.AsSimpleRetentionPolicy() + simpleRetentionPolicy, _ := retentionPolicy.(protectionpolicies.SimpleRetentionPolicy) result.SimpleRetention = flattenBackupProtectionPolicyVMWorkloadSimpleRetention(simpleRetentionPolicy.RetentionDuration) } } @@ -701,26 +695,21 @@ func flattenBackupProtectionPolicyVMWorkloadProtectionPolicies(input *[]backup.S return results } -func expandBackupProtectionPolicyVMWorkloadSchedulePolicy(input ProtectionPolicy, times []date.Time) backup.BasicSchedulePolicy { - if input.PolicyType == string(backup.PolicyTypeLog) { - schedule := backup.LogSchedulePolicy{ - SchedulePolicyType: backup.SchedulePolicyTypeLogSchedulePolicy, - } +func expandBackupProtectionPolicyVMWorkloadSchedulePolicy(input ProtectionPolicy, times []string) protectionpolicies.SchedulePolicy { + if input.PolicyType == string(protectionpolicies.PolicyTypeLog) { + schedule := protectionpolicies.LogSchedulePolicy{} if v := input.Backup[0].FrequencyInMinutes; v != 0 { - schedule.ScheduleFrequencyInMins = utils.Int32(v) + schedule.ScheduleFrequencyInMins = pointer.To(v) } - result, _ := schedule.AsBasicSchedulePolicy() - return result + return schedule } else { - schedule := backup.SimpleSchedulePolicy{ - SchedulePolicyType: backup.SchedulePolicyTypeSimpleSchedulePolicy, - } + schedule := protectionpolicies.SimpleSchedulePolicy{} backupBlock := input.Backup[0] if backupBlock.Frequency != "" { - schedule.ScheduleRunFrequency = backup.ScheduleRunType(backupBlock.Frequency) + schedule.ScheduleRunFrequency = pointer.To(protectionpolicies.ScheduleRunType(backupBlock.Frequency)) } if len(times) > 0 { @@ -728,38 +717,37 @@ func expandBackupProtectionPolicyVMWorkloadSchedulePolicy(input ProtectionPolicy } if v := backupBlock.Weekdays; len(v) > 0 { - days := make([]backup.DayOfWeek, 0) + days := make([]protectionpolicies.DayOfWeek, 0) for _, day := range v { - days = append(days, backup.DayOfWeek(day)) + days = append(days, protectionpolicies.DayOfWeek(day)) } schedule.ScheduleRunDays = &days } - result, _ := schedule.AsBasicSchedulePolicy() - return result + return schedule } } -func flattenBackupProtectionPolicyVMWorkloadSchedulePolicy(input backup.BasicSchedulePolicy, policyType backup.PolicyType) []Backup { +func flattenBackupProtectionPolicyVMWorkloadSchedulePolicy(input protectionpolicies.SchedulePolicy, policyType protectionpolicies.PolicyType) []Backup { if input == nil { return nil } backupBlock := Backup{} - if policyType == backup.PolicyTypeLog { - logSchedulePolicy, _ := input.AsLogSchedulePolicy() + if policyType == protectionpolicies.PolicyTypeLog { + logSchedulePolicy, _ := input.(protectionpolicies.LogSchedulePolicy) if v := logSchedulePolicy.ScheduleFrequencyInMins; v != nil { backupBlock.FrequencyInMinutes = *v } } else { - simpleSchedulePolicy, _ := input.AsSimpleSchedulePolicy() + simpleSchedulePolicy, _ := input.(protectionpolicies.SimpleSchedulePolicy) - backupBlock.Frequency = string(simpleSchedulePolicy.ScheduleRunFrequency) + backupBlock.Frequency = string(pointer.From(simpleSchedulePolicy.ScheduleRunFrequency)) if times := simpleSchedulePolicy.ScheduleRunTimes; times != nil && len(*times) > 0 { - backupBlock.Time = (*times)[0].Format("15:04") + backupBlock.Time = (*times)[0] } if days := simpleSchedulePolicy.ScheduleRunDays; days != nil { @@ -774,20 +762,18 @@ func flattenBackupProtectionPolicyVMWorkloadSchedulePolicy(input backup.BasicSch return []Backup{backupBlock} } -func expandBackupProtectionPolicyVMWorkloadRetentionPolicy(input ProtectionPolicy, times []date.Time) (backup.BasicRetentionPolicy, error) { - if input.PolicyType == string(backup.PolicyTypeFull) { - retentionPolicy := backup.LongTermRetentionPolicy{ - RetentionPolicyType: backup.RetentionPolicyTypeLongTermRetentionPolicy, - } +func expandBackupProtectionPolicyVMWorkloadRetentionPolicy(input ProtectionPolicy, times []string) (protectionpolicies.RetentionPolicy, error) { + if input.PolicyType == string(protectionpolicies.PolicyTypeFull) { + retentionPolicy := protectionpolicies.LongTermRetentionPolicy{} if input.RetentionDaily != nil && len(input.RetentionDaily) > 0 { retentionDaily := input.RetentionDaily[0] - retentionPolicy.DailySchedule = &backup.DailyRetentionSchedule{ + retentionPolicy.DailySchedule = &protectionpolicies.DailyRetentionSchedule{ RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(retentionDaily.Count), - DurationType: backup.RetentionDurationTypeDays, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(retentionDaily.Count), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeDays), }, } } @@ -795,18 +781,18 @@ func expandBackupProtectionPolicyVMWorkloadRetentionPolicy(input ProtectionPolic if input.RetentionWeekly != nil && len(input.RetentionWeekly) > 0 { retentionWeekly := input.RetentionWeekly[0] - retentionPolicy.WeeklySchedule = &backup.WeeklyRetentionSchedule{ + retentionPolicy.WeeklySchedule = &protectionpolicies.WeeklyRetentionSchedule{ RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(retentionWeekly.Count), - DurationType: backup.RetentionDurationTypeWeeks, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(retentionWeekly.Count), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeWeeks), }, } if v := retentionWeekly.Weekdays; len(v) > 0 { - days := make([]backup.DayOfWeek, 0) + days := make([]protectionpolicies.DayOfWeek, 0) for _, day := range v { - days = append(days, backup.DayOfWeek(day)) + days = append(days, protectionpolicies.DayOfWeek(day)) } retentionPolicy.WeeklySchedule.DaysOfTheWeek = &days } @@ -815,26 +801,26 @@ func expandBackupProtectionPolicyVMWorkloadRetentionPolicy(input ProtectionPolic if input.RetentionMonthly != nil && len(input.RetentionMonthly) > 0 { retentionMonthly := input.RetentionMonthly[0] - if input.Backup[0].Frequency == string(backup.ScheduleRunTypeWeekly) && retentionMonthly.FormatType != string(backup.RetentionScheduleFormatWeekly) { + if input.Backup[0].Frequency == string(protectionpolicies.ScheduleRunTypeWeekly) && retentionMonthly.FormatType != string(protectionpolicies.RetentionScheduleFormatWeekly) { return nil, fmt.Errorf("`retention_monthly.format_type` must be `Weekly` when `policy_type` is `Full` and `frequency` is `Weekly`") } - if retentionMonthly.FormatType == string(backup.RetentionScheduleFormatDaily) && (retentionMonthly.Monthdays == nil || len(retentionMonthly.Monthdays) == 0) { + if retentionMonthly.FormatType == string(protectionpolicies.RetentionScheduleFormatDaily) && (retentionMonthly.Monthdays == nil || len(retentionMonthly.Monthdays) == 0) { return nil, fmt.Errorf("`retention_monthly.monthdays` must be set when `retention_monthly.format_type` is `Daily`") } - if retentionMonthly.FormatType == string(backup.RetentionScheduleFormatWeekly) && ((retentionMonthly.Weeks == nil || len(retentionMonthly.Weeks) == 0) || (retentionMonthly.Weekdays == nil || len(retentionMonthly.Weekdays) == 0)) { + if retentionMonthly.FormatType == string(protectionpolicies.RetentionScheduleFormatWeekly) && ((retentionMonthly.Weeks == nil || len(retentionMonthly.Weeks) == 0) || (retentionMonthly.Weekdays == nil || len(retentionMonthly.Weekdays) == 0)) { return nil, fmt.Errorf("`retention_monthly.weeks` and `retention_monthly.weekdays` must be set when `retention_monthly.format_type` is `Weekly`") } - retentionPolicy.MonthlySchedule = &backup.MonthlyRetentionSchedule{ - RetentionScheduleFormatType: backup.RetentionScheduleFormat(retentionMonthly.FormatType), + retentionPolicy.MonthlySchedule = &protectionpolicies.MonthlyRetentionSchedule{ + RetentionScheduleFormatType: pointer.To(protectionpolicies.RetentionScheduleFormat(retentionMonthly.FormatType)), RetentionScheduleDaily: expandBackupProtectionPolicyVMWorkloadRetentionDailyFormat(retentionMonthly.Monthdays), RetentionScheduleWeekly: expandBackupProtectionPolicyVMWorkloadRetentionWeeklyFormat(retentionMonthly.Weekdays, retentionMonthly.Weeks), RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(retentionMonthly.Count), - DurationType: backup.RetentionDurationTypeMonths, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(retentionMonthly.Count), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeMonths), }, } } @@ -842,33 +828,33 @@ func expandBackupProtectionPolicyVMWorkloadRetentionPolicy(input ProtectionPolic if input.RetentionYearly != nil && len(input.RetentionYearly) > 0 { retentionYearly := input.RetentionYearly[0] - if input.Backup[0].Frequency == string(backup.ScheduleRunTypeWeekly) && retentionYearly.FormatType != string(backup.RetentionScheduleFormatWeekly) { + if input.Backup[0].Frequency == string(protectionpolicies.ScheduleRunTypeWeekly) && retentionYearly.FormatType != string(protectionpolicies.RetentionScheduleFormatWeekly) { return nil, fmt.Errorf("`retention_yearly.format_type` must be `Weekly` when `policy_type` is `Full` and `frequency` is `Weekly`") } - if retentionYearly.FormatType == string(backup.RetentionScheduleFormatDaily) && (retentionYearly.Monthdays == nil || len(retentionYearly.Monthdays) == 0) { + if retentionYearly.FormatType == string(protectionpolicies.RetentionScheduleFormatDaily) && (retentionYearly.Monthdays == nil || len(retentionYearly.Monthdays) == 0) { return nil, fmt.Errorf("`retention_yearly.monthdays` must be set when `retention_yearly.format_type` is `Daily`") } - if retentionYearly.FormatType == string(backup.RetentionScheduleFormatWeekly) && ((retentionYearly.Weeks == nil || len(retentionYearly.Weeks) == 0) || (retentionYearly.Weekdays == nil || len(retentionYearly.Weekdays) == 0)) { + if retentionYearly.FormatType == string(protectionpolicies.RetentionScheduleFormatWeekly) && ((retentionYearly.Weeks == nil || len(retentionYearly.Weeks) == 0) || (retentionYearly.Weekdays == nil || len(retentionYearly.Weekdays) == 0)) { return nil, fmt.Errorf("`retention_yearly.weeks` and `retention_yearly.weekdays` must be set when `retention_yearly.format_type` is `Weekly`") } - retentionPolicy.YearlySchedule = &backup.YearlyRetentionSchedule{ - RetentionScheduleFormatType: backup.RetentionScheduleFormat(retentionYearly.FormatType), + retentionPolicy.YearlySchedule = &protectionpolicies.YearlyRetentionSchedule{ + RetentionScheduleFormatType: pointer.To(protectionpolicies.RetentionScheduleFormat(retentionYearly.FormatType)), RetentionScheduleDaily: expandBackupProtectionPolicyVMWorkloadRetentionDailyFormat(retentionYearly.Monthdays), RetentionScheduleWeekly: expandBackupProtectionPolicyVMWorkloadRetentionWeeklyFormat(retentionYearly.Weekdays, retentionYearly.Weeks), RetentionTimes: ×, - RetentionDuration: &backup.RetentionDuration{ - Count: utils.Int32(retentionYearly.Count), - DurationType: backup.RetentionDurationTypeYears, + RetentionDuration: &protectionpolicies.RetentionDuration{ + Count: pointer.To(retentionYearly.Count), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeYears), }, } if v := retentionYearly.Months; v != nil { - months := make([]backup.MonthOfYear, 0) + months := make([]protectionpolicies.MonthOfYear, 0) for _, month := range v { - months = append(months, backup.MonthOfYear(month)) + months = append(months, protectionpolicies.MonthOfYear(month)) } retentionPolicy.YearlySchedule.MonthsOfYear = &months } @@ -876,16 +862,14 @@ func expandBackupProtectionPolicyVMWorkloadRetentionPolicy(input ProtectionPolic return retentionPolicy, nil } else { - retentionPolicy := backup.SimpleRetentionPolicy{ - RetentionPolicyType: backup.RetentionPolicyTypeSimpleRetentionPolicy, - } + retentionPolicy := protectionpolicies.SimpleRetentionPolicy{} if input.SimpleRetention != nil && len(input.SimpleRetention) > 0 { simpleRetention := input.SimpleRetention[0] - retentionPolicy.RetentionDuration = &backup.RetentionDuration{ - Count: utils.Int32(simpleRetention.Count), - DurationType: backup.RetentionDurationTypeDays, + retentionPolicy.RetentionDuration = &protectionpolicies.RetentionDuration{ + Count: pointer.To(simpleRetention.Count), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeDays), } } @@ -893,7 +877,7 @@ func expandBackupProtectionPolicyVMWorkloadRetentionPolicy(input ProtectionPolic } } -func flattenBackupProtectionPolicyVMWorkloadRetentionDaily(input *backup.DailyRetentionSchedule) []RetentionDaily { +func flattenBackupProtectionPolicyVMWorkloadRetentionDaily(input *protectionpolicies.DailyRetentionSchedule) []RetentionDaily { if input == nil { return nil } @@ -909,7 +893,7 @@ func flattenBackupProtectionPolicyVMWorkloadRetentionDaily(input *backup.DailyRe return []RetentionDaily{retentionDailyBlock} } -func flattenBackupProtectionPolicyVMWorkloadRetentionWeekly(input *backup.WeeklyRetentionSchedule) []RetentionWeekly { +func flattenBackupProtectionPolicyVMWorkloadRetentionWeekly(input *protectionpolicies.WeeklyRetentionSchedule) []RetentionWeekly { if input == nil { return nil } @@ -933,7 +917,7 @@ func flattenBackupProtectionPolicyVMWorkloadRetentionWeekly(input *backup.Weekly return []RetentionWeekly{retentionWeeklyBlock} } -func flattenBackupProtectionPolicyVMWorkloadRetentionMonthly(input *backup.MonthlyRetentionSchedule) []RetentionMonthly { +func flattenBackupProtectionPolicyVMWorkloadRetentionMonthly(input *protectionpolicies.MonthlyRetentionSchedule) []RetentionMonthly { if input == nil { return nil } @@ -946,7 +930,7 @@ func flattenBackupProtectionPolicyVMWorkloadRetentionMonthly(input *backup.Month } } - if formatType := input.RetentionScheduleFormatType; formatType != "" { + if formatType := pointer.From(input.RetentionScheduleFormatType); formatType != "" { retentionMonthlyBlock.FormatType = string(formatType) } @@ -961,7 +945,7 @@ func flattenBackupProtectionPolicyVMWorkloadRetentionMonthly(input *backup.Month return []RetentionMonthly{retentionMonthlyBlock} } -func flattenBackupProtectionPolicyVMWorkloadRetentionYearly(input *backup.YearlyRetentionSchedule) []RetentionYearly { +func flattenBackupProtectionPolicyVMWorkloadRetentionYearly(input *protectionpolicies.YearlyRetentionSchedule) []RetentionYearly { if input == nil { return nil } @@ -974,7 +958,7 @@ func flattenBackupProtectionPolicyVMWorkloadRetentionYearly(input *backup.Yearly } } - if formatType := input.RetentionScheduleFormatType; formatType != "" { + if formatType := pointer.From(input.RetentionScheduleFormatType); formatType != "" { retentionYearlyBlock.FormatType = string(formatType) } @@ -997,7 +981,7 @@ func flattenBackupProtectionPolicyVMWorkloadRetentionYearly(input *backup.Yearly return []RetentionYearly{retentionYearlyBlock} } -func flattenBackupProtectionPolicyVMWorkloadSimpleRetention(input *backup.RetentionDuration) []SimpleRetention { +func flattenBackupProtectionPolicyVMWorkloadSimpleRetention(input *protectionpolicies.RetentionDuration) []SimpleRetention { if input == nil { return nil } @@ -1011,17 +995,17 @@ func flattenBackupProtectionPolicyVMWorkloadSimpleRetention(input *backup.Retent return []SimpleRetention{simpleRetentionBlock} } -func expandBackupProtectionPolicyVMWorkloadRetentionDailyFormat(input []int) *backup.DailyRetentionFormat { +func expandBackupProtectionPolicyVMWorkloadRetentionDailyFormat(input []int) *protectionpolicies.DailyRetentionFormat { if len(input) == 0 { return nil } - daily := backup.DailyRetentionFormat{} + daily := protectionpolicies.DailyRetentionFormat{} - days := make([]backup.Day, 0) + days := make([]protectionpolicies.Day, 0) for _, item := range input { - day := backup.Day{ - Date: utils.Int32(int32((item))), + day := protectionpolicies.Day{ + Date: pointer.To(int64(item)), } if item == 0 { @@ -1037,25 +1021,25 @@ func expandBackupProtectionPolicyVMWorkloadRetentionDailyFormat(input []int) *ba return &daily } -func expandBackupProtectionPolicyVMWorkloadRetentionWeeklyFormat(weekdays, weeks []string) *backup.WeeklyRetentionFormat { +func expandBackupProtectionPolicyVMWorkloadRetentionWeeklyFormat(weekdays, weeks []string) *protectionpolicies.WeeklyRetentionFormat { if len(weekdays) == 0 && len(weeks) == 0 { return nil } - weekly := backup.WeeklyRetentionFormat{} + weekly := protectionpolicies.WeeklyRetentionFormat{} if len(weekdays) > 0 { - weekdaysBlock := make([]backup.DayOfWeek, 0) + weekdaysBlock := make([]protectionpolicies.DayOfWeek, 0) for _, day := range weekdays { - weekdaysBlock = append(weekdaysBlock, backup.DayOfWeek(day)) + weekdaysBlock = append(weekdaysBlock, protectionpolicies.DayOfWeek(day)) } weekly.DaysOfTheWeek = &weekdaysBlock } if len(weeks) > 0 { - weeksBlock := make([]backup.WeekOfMonth, 0) + weeksBlock := make([]protectionpolicies.WeekOfMonth, 0) for _, week := range weeks { - weeksBlock = append(weeksBlock, backup.WeekOfMonth(week)) + weeksBlock = append(weeksBlock, protectionpolicies.WeekOfMonth(week)) } weekly.WeeksOfTheMonth = &weeksBlock } @@ -1063,7 +1047,7 @@ func expandBackupProtectionPolicyVMWorkloadRetentionWeeklyFormat(weekdays, weeks return &weekly } -func flattenBackupProtectionPolicyVMWorkloadRetentionWeeklyFormat(input *backup.WeeklyRetentionFormat) (weekdays, weeks []string) { +func flattenBackupProtectionPolicyVMWorkloadRetentionWeeklyFormat(input *protectionpolicies.WeeklyRetentionFormat) (weekdays, weeks []string) { if v := input.DaysOfTheWeek; v != nil { days := make([]string, 0) for _, d := range *v { @@ -1083,7 +1067,7 @@ func flattenBackupProtectionPolicyVMWorkloadRetentionWeeklyFormat(input *backup. return weekdays, weeks } -func flattenBackupProtectionPolicyVMWorkloadRetentionDailyFormat(input *backup.DailyRetentionFormat) []int { +func flattenBackupProtectionPolicyVMWorkloadRetentionDailyFormat(input *protectionpolicies.DailyRetentionFormat) []int { result := make([]int, 0) if days := input.DaysOfTheMonth; days != nil { diff --git a/internal/services/recoveryservices/backup_policy_vm_workload_resource_test.go b/internal/services/recoveryservices/backup_policy_vm_workload_resource_test.go index c17fae6af74c..97e9ed7c0292 100644 --- a/internal/services/recoveryservices/backup_policy_vm_workload_resource_test.go +++ b/internal/services/recoveryservices/backup_policy_vm_workload_resource_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -53,17 +53,17 @@ func TestAccBackupProtectionPolicyVMWorkload_update(t *testing.T) { } func (t BackupProtectionPolicyVMWorkloadResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.BackupPolicyID(state.ID) + id, err := protectionpolicies.ParseBackupPolicyID(state.ID) if err != nil { return nil, err } - resp, err := clients.RecoveryServices.ProtectionPoliciesClient.Get(ctx, id.VaultName, id.ResourceGroup, id.Name) + resp, err := clients.RecoveryServices.ProtectionPoliciesClient.Get(ctx, *id) if err != nil { return nil, fmt.Errorf("reading Recovery Service Protection Policy (%s): %+v", id.String(), err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (r BackupProtectionPolicyVMWorkloadResource) basic(data acceptance.TestData) string { diff --git a/internal/services/recoveryservices/backup_protected_file_share_resource.go b/internal/services/recoveryservices/backup_protected_file_share_resource.go index ca55510c3928..e233f770b08f 100644 --- a/internal/services/recoveryservices/backup_protected_file_share_resource.go +++ b/internal/services/recoveryservices/backup_protected_file_share_resource.go @@ -9,7 +9,13 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -81,6 +87,7 @@ func resourceBackupProtectedFileShareCreateUpdate(d *pluginsdk.ResourceData, met client := meta.(*clients.Client).RecoveryServices.ProtectedItemsClient opClient := meta.(*clients.Client).RecoveryServices.BackupOperationStatusesClient opResultClient := meta.(*clients.Client).RecoveryServices.ProtectionContainerOperationResultsClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -91,6 +98,8 @@ func resourceBackupProtectedFileShareCreateUpdate(d *pluginsdk.ResourceData, met fileShareName := d.Get("source_file_share_name").(string) policyID := d.Get("backup_policy_id").(string) + vaultId := backupprotectableitems.NewVaultID(subscriptionId, d.Get("resource_group_name").(string), d.Get("recovery_vault_name").(string)) + // get storage account name from id parsedStorageAccountID, err := storageParse.StorageAccountID(storageAccountID) if err != nil { @@ -107,16 +116,18 @@ func resourceBackupProtectedFileShareCreateUpdate(d *pluginsdk.ResourceData, met // this means which means we have to do it client side and loop over backupProtectedItems en backupProtectableItems until share is found filter := "backupManagementType eq 'AzureStorage'" + protectionContainerId := protectioncontainers.NewProtectionContainerID(subscriptionId, resourceGroup, vaultName, "Azure", containerName) + // There is an issue https://github.com/hashicorp/terraform-provider-azurerm/issues/11184 (When a new file share is added to an exist storage account, // it cannot be listed by Backup Protectable Items - List API after the storage account is registered with a RSV). // After confirming with the service team, whenever new file shares are added, we need to run an 'inquire' API. but inquiry APIs are long running APIs and hence can't be included in GET API's (Backup Protectable Items - List) response. // Therefore, add 'inquire' API to inquire all unprotected files shares under a storage account to fix this usecase. - respContainer, err := protectionContainerClient.Inquire(ctx, vaultName, resourceGroup, "Azure", containerName, filter) + respContainer, err := protectionContainerClient.Inquire(ctx, protectionContainerId, protectioncontainers.InquireOperationOptions{pointer.To(filter)}) if err != nil { return fmt.Errorf("inquire all unprotected files shares under a storage account %q (Resource Group %q): %+v", parsedStorageAccountID.Name, resourceGroup, err) } - locationURL, err := respContainer.Response.Location() + locationURL, err := respContainer.HttpResponse.Location() if err != nil || locationURL == nil { return fmt.Errorf("inquire all unprotected files shares %q (Vault %q): Location header missing or empty", containerName, vaultName) } @@ -150,41 +161,49 @@ func resourceBackupProtectedFileShareCreateUpdate(d *pluginsdk.ResourceData, met return fmt.Errorf("waiting for Recovery Service Protection Container operation %q (Vault %q in Resource Group %q): %+v", operationID, vaultName, resourceGroup, err) } - backupProtectableItemsResponse, err := protectableClient.List(ctx, vaultName, resourceGroup, filter, "") + backupProtectableItemsListOptions := backupprotectableitems.ListOperationOptions{ + Filter: pointer.To(filter), + } + backupProtectableItemsResponse, err := protectableClient.List(ctx, vaultId, backupProtectableItemsListOptions) if err != nil { return fmt.Errorf("checking for protectable fileshares in Recovery Service Vault %q (Resource Group %q): %+v", vaultName, resourceGroup, err) } - for _, protectableItem := range backupProtectableItemsResponse.Values() { - if *protectableItem.Name == "" || protectableItem.Properties == nil { - continue - } - azureFileShareProtectableItem, check := protectableItem.Properties.AsAzureFileShareProtectableItem() + if backupProtectableItemsResponse.Model != nil { + for _, protectableItem := range *backupProtectableItemsResponse.Model { + if *protectableItem.Name == "" || protectableItem.Properties == nil { + continue + } + azureFileShareProtectableItem, check := protectableItem.Properties.(backupprotectableitems.AzureFileShareProtectableItem) - // check if protected item has the same fileshare name and is from the same storage account - if check && *azureFileShareProtectableItem.FriendlyName == fileShareName && *azureFileShareProtectableItem.ParentContainerFriendlyName == parsedStorageAccountID.Name { - fileShareSystemName = *protectableItem.Name - break + // check if protected item has the same fileshare name and is from the same storage account + if check && *azureFileShareProtectableItem.FriendlyName == fileShareName && *azureFileShareProtectableItem.ParentContainerFriendlyName == parsedStorageAccountID.Name { + fileShareSystemName = *protectableItem.Name + break + } } } // fileShareSystemName not found? Check if already protected by this vault! if fileShareSystemName == "" { - backupProtectedItemsResponse, err := protectedClient.List(ctx, vaultName, resourceGroup, filter, "") + vaultId := backupprotecteditems.NewVaultID(subscriptionId, d.Get("resource_group_name").(string), d.Get("recovery_vault_name").(string)) + backupProtectedItemsResponse, err := protectedClient.List(ctx, vaultId, backupprotecteditems.ListOperationOptions{}) if err != nil { return fmt.Errorf("checking for protected fileshares in Recovery Service Vault %q (Resource Group %q): %+v", vaultName, resourceGroup, err) } - for _, protectedItem := range backupProtectedItemsResponse.Values() { - if *protectedItem.Name == "" || protectedItem.Properties == nil { - continue - } - azureFileShareProtectedItem, check := protectedItem.Properties.AsAzureFileshareProtectedItem() - - // check if protected item has the same fileshare name and is from the same storage account - if check && *azureFileShareProtectedItem.FriendlyName == fileShareName && strings.EqualFold(*azureFileShareProtectedItem.SourceResourceID, storageAccountID) { - fileShareSystemName = *protectedItem.Name - break + if model := backupProtectedItemsResponse.Model; model != nil { + for _, protectedItem := range *model { + if *protectedItem.Name == "" || protectedItem.Properties == nil { + continue + } + azureFileShareProtectedItem, check := protectedItem.Properties.(backupprotecteditems.AzureFileshareProtectedItem) + + // check if protected item has the same fileshare name and is from the same storage account + if check && *azureFileShareProtectedItem.FriendlyName == fileShareName && strings.EqualFold(*azureFileShareProtectedItem.SourceResourceId, storageAccountID) { + fileShareSystemName = *protectedItem.Name + break + } } } } @@ -192,40 +211,41 @@ func resourceBackupProtectedFileShareCreateUpdate(d *pluginsdk.ResourceData, met return fmt.Errorf("[ERROR] fileshare '%s' not found in protectable or protected fileshares, make sure Storage Account %q is registered with Recovery Service Vault %q (Resource Group %q)", fileShareName, parsedStorageAccountID.Name, vaultName, resourceGroup) } + id := protecteditems.NewProtectedItemID(subscriptionId, d.Get("resource_group_name").(string), d.Get("recovery_vault_name").(string), "Azure", containerName, fileShareSystemName) + if d.IsNewResource() { - existing, err2 := client.Get(ctx, vaultName, resourceGroup, "Azure", containerName, fileShareSystemName, "") + existing, err2 := client.Get(ctx, id, protecteditems.GetOperationOptions{}) if err2 != nil { - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing Recovery Service Protected File Share %q (Resource Group %q): %+v", fileShareName, resourceGroup, err2) } } - if existing.ID != nil && *existing.ID != "" { - return tf.ImportAsExistsError("azurerm_backup_protected_file_share", *existing.ID) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_backup_protected_file_share", id.ID()) } } - item := backup.ProtectedItemResource{ - Properties: &backup.AzureFileshareProtectedItem{ - PolicyID: &policyID, - ProtectedItemType: backup.ProtectedItemTypeAzureFileShareProtectedItem, - WorkloadType: backup.DataSourceTypeAzureFileShare, - SourceResourceID: utils.String(storageAccountID), - FriendlyName: utils.String(fileShareName), + item := protecteditems.ProtectedItemResource{ + Properties: &protecteditems.AzureFileshareProtectedItem{ + PolicyId: &policyID, + WorkloadType: pointer.To(protecteditems.DataSourceTypeAzureFileShare), + SourceResourceId: utils.String(storageAccountID), + FriendlyName: utils.String(fileShareName), }, } - resp, err := client.CreateOrUpdate(ctx, vaultName, resourceGroup, "Azure", containerName, fileShareSystemName, item) + resp, err := client.CreateOrUpdate(ctx, id, item) if err != nil { return fmt.Errorf("creating/updating Recovery Service Protected File Share %q (Resource Group %q): %+v", fileShareName, resourceGroup, err) } - locationURL, err = resp.Response.Location() + locationURL, err = resp.HttpResponse.Location() if err != nil || locationURL == nil { return fmt.Errorf("creating/updating Azure File Share backup item %q (Vault %q): Location header missing or empty", containerName, vaultName) } - opResourceID = handleAzureSdkForGoBug2824(locationURL.Path) + opResourceID = handleAzureSdkForGoBug2824(locationURL.String()) parsedLocation, err = azure.ParseAzureResourceID(opResourceID) if err != nil { @@ -237,14 +257,7 @@ func resourceBackupProtectedFileShareCreateUpdate(d *pluginsdk.ResourceData, met return err } - resp, err = client.Get(ctx, vaultName, resourceGroup, "Azure", containerName, fileShareSystemName, "") - - if err != nil { - return fmt.Errorf("creating/updating Azure File Share backup item %q (Vault %q): %+v", fileShareName, vaultName, err) - } - - id := strings.Replace(*resp.ID, "Subscriptions", "subscriptions", 1) // This code is a workaround for this bug https://github.com/Azure/azure-sdk-for-go/issues/2824 - d.SetId(id) + d.SetId(id.ID()) return resourceBackupProtectedFileShareRead(d, meta) } @@ -254,34 +267,38 @@ func resourceBackupProtectedFileShareRead(d *pluginsdk.ResourceData, meta interf ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ProtectedItemID(d.Id()) + id, err := protecteditems.ParseProtectedItemID(d.Id()) if err != nil { return err } - log.Printf("[DEBUG] Reading Recovery Service Protected File Share %q (resource group %q)", id.Name, id.ResourceGroup) + log.Printf("[DEBUG] Reading %s", *id) - resp, err := client.Get(ctx, id.VaultName, id.ResourceGroup, "Azure", id.ProtectionContainerName, id.Name, "") + resp, err := client.Get(ctx, *id, protecteditems.GetOperationOptions{}) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("making Read request on Recovery Service Protected File Share %q (Vault %q Resource Group %q): %+v", id.Name, id.VaultName, id.ResourceGroup, err) + return fmt.Errorf("making Read request on %s: %+v", id, err) } - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("recovery_vault_name", id.VaultName) - if properties := resp.Properties; properties != nil { - if item, ok := properties.AsAzureFileshareProtectedItem(); ok { - sourceResourceID := strings.Replace(*item.SourceResourceID, "Microsoft.storage", "Microsoft.Storage", 1) // The SDK is returning inconsistent capitalization - d.Set("source_storage_account_id", sourceResourceID) - d.Set("source_file_share_name", item.FriendlyName) - - if v := item.PolicyID; v != nil { - d.Set("backup_policy_id", strings.Replace(*v, "Subscriptions", "subscriptions", 1)) + if model := resp.Model; model != nil { + if properties := model.Properties; properties != nil { + if item, ok := properties.(protecteditems.AzureFileshareProtectedItem); ok { + if item.SourceResourceId != nil { + sourceResourceID := strings.Replace(*item.SourceResourceId, "Microsoft.storage", "Microsoft.Storage", 1) // The SDK is returning inconsistent capitalization + d.Set("source_storage_account_id", sourceResourceID) + } + d.Set("source_file_share_name", item.FriendlyName) + + if v := item.PolicyId; v != nil { + d.Set("backup_policy_id", strings.Replace(*v, "Subscriptions", "subscriptions", 1)) + } } } } @@ -295,21 +312,21 @@ func resourceBackupProtectedFileShareDelete(d *pluginsdk.ResourceData, meta inte ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ProtectedItemID(d.Id()) + id, err := protecteditems.ParseProtectedItemID(d.Id()) if err != nil { return err } - log.Printf("[DEBUG] Deleting Recovery Service Protected Item %q (resource group %q)", id.Name, id.ResourceGroup) + log.Printf("[DEBUG] Deleting %s", *id) - resp, err := client.Delete(ctx, id.VaultName, id.ResourceGroup, "Azure", id.ProtectionContainerName, id.Name) + resp, err := client.Delete(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("issuing delete request for Recovery Service Protected File Share %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + if !response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("issuing delete request for %s: %+v", id, err) } } - locationURL, err := resp.Response.Location() + locationURL, err := resp.HttpResponse.Location() if err != nil || locationURL == nil { return fmt.Errorf("deleting Azure File Share backups item %s (Vault %s): Location header missing or empty", id.ProtectionContainerName, id.VaultName) } @@ -322,7 +339,7 @@ func resourceBackupProtectedFileShareDelete(d *pluginsdk.ResourceData, meta inte } operationID := parsedLocation.Path["backupOperationResults"] // This is different for create and delete requests ¯\_(ツ)_/¯ - if _, err := resourceBackupProtectedFileShareWaitForOperation(ctx, opClient, id.VaultName, id.ResourceGroup, operationID, d); err != nil { + if _, err := resourceBackupProtectedFileShareWaitForOperation(ctx, opClient, id.VaultName, id.ResourceGroupName, operationID, d); err != nil { return err } diff --git a/internal/services/recoveryservices/backup_protected_file_share_resource_test.go b/internal/services/recoveryservices/backup_protected_file_share_resource_test.go index d35674d7b541..6b518be69394 100644 --- a/internal/services/recoveryservices/backup_protected_file_share_resource_test.go +++ b/internal/services/recoveryservices/backup_protected_file_share_resource_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -107,17 +107,17 @@ func TestAccBackupProtectedFileShare_updateBackupPolicyId(t *testing.T) { } func (t BackupProtectedFileShareResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.ProtectedItemID(state.ID) + id, err := protecteditems.ParseProtectedItemID(state.ID) if err != nil { return nil, err } - resp, err := clients.RecoveryServices.ProtectedItemsClient.Get(ctx, id.VaultName, id.ResourceGroup, "Azure", id.ProtectionContainerName, id.Name, "") + resp, err := clients.RecoveryServices.ProtectedItemsClient.Get(ctx, *id, protecteditems.GetOperationOptions{}) if err != nil { return nil, fmt.Errorf("reading Recovery Service Protected File Share (%s): %+v", id.String(), err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (BackupProtectedFileShareResource) base(data acceptance.TestData) string { diff --git a/internal/services/recoveryservices/backup_protected_vm_resource.go b/internal/services/recoveryservices/backup_protected_vm_resource.go index a0dfba0a7579..5e6bf318e98e 100644 --- a/internal/services/recoveryservices/backup_protected_vm_resource.go +++ b/internal/services/recoveryservices/backup_protected_vm_resource.go @@ -9,12 +9,14 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" vmParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" @@ -31,7 +33,7 @@ func resourceRecoveryServicesBackupProtectedVM() *pluginsdk.Resource { Delete: resourceRecoveryServicesBackupProtectedVMDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.ProtectedItemID(id) + _, err := protecteditems.ParseProtectedItemID(id) return err }), @@ -54,6 +56,7 @@ func resourceRecoveryServicesBackupProtectedVM() *pluginsdk.Resource { func resourceRecoveryServicesBackupProtectedVMCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).RecoveryServices.ProtectedItemsClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -81,42 +84,41 @@ func resourceRecoveryServicesBackupProtectedVMCreateUpdate(d *pluginsdk.Resource log.Printf("[DEBUG] Creating/updating Azure Backup Protected VM %s (resource group %q)", protectedItemName, resourceGroup) + id := protecteditems.NewProtectedItemID(subscriptionId, resourceGroup, vaultName, "Azure", containerName, protectedItemName) if d.IsNewResource() { - existing, err2 := client.Get(ctx, vaultName, resourceGroup, "Azure", containerName, protectedItemName, "") - if err2 != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing Azure Backup Protected VM %q (Resource Group %q): %+v", protectedItemName, resourceGroup, err2) + existing, err := client.Get(ctx, id, protecteditems.GetOperationOptions{}) + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if existing.ID != nil && *existing.ID != "" { - return tf.ImportAsExistsError("azurerm_backup_protected_vm", *existing.ID) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_backup_protected_vm", id.ID()) } } - item := backup.ProtectedItemResource{ - Properties: &backup.AzureIaaSComputeVMProtectedItem{ - PolicyID: &policyId, - ProtectedItemType: backup.ProtectedItemTypeMicrosoftClassicComputevirtualMachines, - WorkloadType: backup.DataSourceTypeVM, - SourceResourceID: utils.String(vmId), - FriendlyName: utils.String(parsedVmId.Name), + item := protecteditems.ProtectedItemResource{ + Properties: &protecteditems.AzureIaaSComputeVMProtectedItem{ + PolicyId: &policyId, + WorkloadType: pointer.To(protecteditems.DataSourceTypeVM), + SourceResourceId: pointer.To(vmId), + FriendlyName: pointer.To(parsedVmId.Name), ExtendedProperties: expandDiskExclusion(d), - VirtualMachineID: utils.String(vmId), + VirtualMachineId: pointer.To(vmId), }, } - if _, err = client.CreateOrUpdate(ctx, vaultName, resourceGroup, "Azure", containerName, protectedItemName, item); err != nil { + if _, err = client.CreateOrUpdate(ctx, id, item); err != nil { return fmt.Errorf("creating/updating Azure Backup Protected VM %q (Resource Group %q): %+v", protectedItemName, resourceGroup, err) } - resp, err := resourceRecoveryServicesBackupProtectedVMWaitForStateCreateUpdate(ctx, client, vaultName, resourceGroup, containerName, protectedItemName, d) + _, err = resourceRecoveryServicesBackupProtectedVMWaitForStateCreateUpdate(ctx, client, id, d) if err != nil { return err } - id := strings.Replace(*resp.ID, "Subscriptions", "subscriptions", 1) // This code is a workaround for this bug https://github.com/Azure/azure-sdk-for-go/issues/2824 - d.SetId(id) + d.SetId(id.ID()) return resourceRecoveryServicesBackupProtectedVMRead(d, meta) } @@ -126,42 +128,44 @@ func resourceRecoveryServicesBackupProtectedVMRead(d *pluginsdk.ResourceData, me ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ProtectedItemID(d.Id()) + id, err := protecteditems.ParseProtectedItemID(d.Id()) if err != nil { return err } - log.Printf("[DEBUG] Reading Azure Backup Protected VM %q (resource group %q)", id.Name, id.ResourceGroup) + log.Printf("[DEBUG] Reading %s", id) - resp, err := client.Get(ctx, id.VaultName, id.ResourceGroup, "Azure", id.ProtectionContainerName, id.Name, "") + resp, err := client.Get(ctx, *id, protecteditems.GetOperationOptions{}) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("making Read request on Azure Backup Protected VM %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + return fmt.Errorf("making Read request on %s: %+v", id, err) } - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("recovery_vault_name", id.VaultName) - if properties := resp.Properties; properties != nil { - if vm, ok := properties.AsAzureIaaSComputeVMProtectedItem(); ok { - d.Set("source_vm_id", vm.SourceResourceID) + if model := resp.Model; model != nil { + if properties := model.Properties; properties != nil { + if vm, ok := properties.(protecteditems.AzureIaaSComputeVMProtectedItem); ok { + d.Set("source_vm_id", vm.SourceResourceId) - if v := vm.PolicyID; v != nil { - d.Set("backup_policy_id", strings.Replace(*v, "Subscriptions", "subscriptions", 1)) - } + if v := vm.PolicyId; v != nil { + d.Set("backup_policy_id", strings.Replace(*v, "Subscriptions", "subscriptions", 1)) + } - if v := vm.ExtendedProperties; v != nil && v.DiskExclusionProperties != nil { - if *v.DiskExclusionProperties.IsInclusionList { - if err := d.Set("include_disk_luns", utils.FlattenInt32Slice(v.DiskExclusionProperties.DiskLunList)); err != nil { - return fmt.Errorf("setting include_disk_luns: %+v", err) - } - } else { - if err := d.Set("exclude_disk_luns", utils.FlattenInt32Slice(v.DiskExclusionProperties.DiskLunList)); err != nil { - return fmt.Errorf("setting exclude_disk_luns: %+v", err) + if v := vm.ExtendedProperties; v != nil && v.DiskExclusionProperties != nil { + if *v.DiskExclusionProperties.IsInclusionList { + if err := d.Set("include_disk_luns", utils.FlattenInt64Slice(v.DiskExclusionProperties.DiskLunList)); err != nil { + return fmt.Errorf("setting include_disk_luns: %+v", err) + } + } else { + if err := d.Set("exclude_disk_luns", utils.FlattenInt64Slice(v.DiskExclusionProperties.DiskLunList)); err != nil { + return fmt.Errorf("setting exclude_disk_luns: %+v", err) + } } } } @@ -177,21 +181,21 @@ func resourceRecoveryServicesBackupProtectedVMDelete(d *pluginsdk.ResourceData, ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ProtectedItemID(d.Id()) + id, err := protecteditems.ParseProtectedItemID(d.Id()) if err != nil { return err } - log.Printf("[DEBUG] Deleting Azure Backup Protected Item %q (resource group %q)", id.Name, id.ResourceGroup) + log.Printf("[DEBUG] Deleting %s", id) - resp, err := client.Delete(ctx, id.VaultName, id.ResourceGroup, "Azure", id.ProtectionContainerName, id.Name) + resp, err := client.Delete(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("issuing delete request for Azure Backup Protected VM %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + if !response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("issuing delete request for %s: %+v", id, err) } } - locationURL, err := resp.Response.Location() + locationURL, err := resp.HttpResponse.Location() if err != nil || locationURL == nil { return fmt.Errorf("deleting %s: Location header missing or empty", id) } @@ -201,20 +205,20 @@ func resourceRecoveryServicesBackupProtectedVMDelete(d *pluginsdk.ResourceData, return err } - if _, err := resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx, client, opResultClient, id.VaultName, id.ResourceGroup, id.ProtectionContainerName, id.Name, parsedLocation.Path["backupOperationResults"], d); err != nil { + if _, err := resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx, client, opResultClient, *id, parsedLocation.Path["backupOperationResults"], d); err != nil { return err } return nil } -func resourceRecoveryServicesBackupProtectedVMWaitForStateCreateUpdate(ctx context.Context, client *backup.ProtectedItemsClient, vaultName, resourceGroup, containerName, protectedItemName string, d *pluginsdk.ResourceData) (backup.ProtectedItemResource, error) { +func resourceRecoveryServicesBackupProtectedVMWaitForStateCreateUpdate(ctx context.Context, client *protecteditems.ProtectedItemsClient, id protecteditems.ProtectedItemId, d *pluginsdk.ResourceData) (backup.ProtectedItemResource, error) { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, Pending: []string{"NotFound"}, Target: []string{"Found"}, - Refresh: resourceRecoveryServicesBackupProtectedVMRefreshFunc(ctx, client, vaultName, resourceGroup, containerName, protectedItemName), + Refresh: resourceRecoveryServicesBackupProtectedVMRefreshFunc(ctx, client, id), } if d.IsNewResource() { @@ -226,32 +230,34 @@ func resourceRecoveryServicesBackupProtectedVMWaitForStateCreateUpdate(ctx conte resp, err := state.WaitForStateContext(ctx) if err != nil { i, _ := resp.(backup.ProtectedItemResource) - return i, fmt.Errorf("waiting for the Azure Backup Protected VM %q to be true (Resource Group %q) to provision: %+v", protectedItemName, resourceGroup, err) + return i, fmt.Errorf("waiting for %s to provision: %+v", id, err) } return resp.(backup.ProtectedItemResource), nil } -func resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx context.Context, client *backup.ProtectedItemsClient, opResultClient *backup.OperationResultsClient, vaultName, resourceGroup, containerName, protectedItemName, operationId string, d *pluginsdk.ResourceData) (backup.ProtectedItemResource, error) { +func resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx context.Context, client *protecteditems.ProtectedItemsClient, opResultClient *backup.OperationResultsClient, id protecteditems.ProtectedItemId, operationId string, d *pluginsdk.ResourceData) (backup.ProtectedItemResource, error) { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, Pending: []string{"Pending"}, Target: []string{"NotFound", "Stopped"}, Refresh: func() (interface{}, string, error) { - resp, err := client.Get(ctx, vaultName, resourceGroup, "Azure", containerName, protectedItemName, "") + resp, err := client.Get(ctx, id, protecteditems.GetOperationOptions{}) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return resp, "NotFound", nil } - return resp, "Error", fmt.Errorf("making Read request on Azure Backup Protected VM %q (Resource Group %q): %+v", protectedItemName, resourceGroup, err) + return resp, "Error", fmt.Errorf("making Read request on %s: %+v", id, err) } - if properties := resp.Properties; properties != nil { - if vm, ok := properties.AsAzureIaaSComputeVMProtectedItem(); ok { - if strings.EqualFold(string(vm.ProtectionState), string(backup.ProtectionStateProtectionStopped)) { - return resp, "Stopped", nil + if model := resp.Model; model != nil { + if properties := model.Properties; properties != nil { + if vm, ok := properties.(protecteditems.AzureIaaSComputeVMProtectedItem); ok { + if vm.ProtectionState != nil && strings.EqualFold(string(*vm.ProtectionState), string(backup.ProtectionStateProtectionStopped)) { + return resp, "Stopped", nil + } } } } @@ -264,7 +270,7 @@ func resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx context.Contex resp, err := state.WaitForStateContext(ctx) if err != nil { i, _ := resp.(backup.ProtectedItemResource) - return i, fmt.Errorf("waiting for the Azure Backup Protected VM %q to be deleted (Resource Group %q): %+v", protectedItemName, resourceGroup, err) + return i, fmt.Errorf("waiting for %s: %+v", id, err) } // we should also wait for the operation to complete, or it will fail when creating a new backup vm with the same vm in different vault immediately. @@ -274,9 +280,9 @@ func resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx context.Contex Pending: []string{"202"}, Target: []string{"200", "204"}, Refresh: func() (interface{}, string, error) { - resp, err := opResultClient.Get(ctx, vaultName, resourceGroup, operationId) + resp, err := opResultClient.Get(ctx, id.VaultName, id.ResourceGroupName, operationId) if err != nil { - return nil, "Error", fmt.Errorf("making Read request on Recovery Service Protected Item operation %q (Vault %q in Resource Group %q): %+v", operationId, vaultName, resourceGroup, err) + return nil, "Error", fmt.Errorf("making Read request on Recovery Service Protected Item operation %q for %s: %+v", operationId, id, err) } return resp, strconv.Itoa(resp.StatusCode), err }, @@ -286,33 +292,33 @@ func resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx context.Contex _, err = opState.WaitForStateContext(ctx) if err != nil { - return resp.(backup.ProtectedItemResource), fmt.Errorf("waiting for the Recovery Service Protected Item operation %q to be deleted (Resource Group %q): %+v", containerName, resourceGroup, err) + return resp.(backup.ProtectedItemResource), fmt.Errorf("waiting for the Recovery Service Protected Item operation to be deleted for %s: %+v", id, err) } return resp.(backup.ProtectedItemResource), nil } -func resourceRecoveryServicesBackupProtectedVMRefreshFunc(ctx context.Context, client *backup.ProtectedItemsClient, vaultName, resourceGroup, containerName, protectedItemName string) pluginsdk.StateRefreshFunc { +func resourceRecoveryServicesBackupProtectedVMRefreshFunc(ctx context.Context, client *protecteditems.ProtectedItemsClient, id protecteditems.ProtectedItemId) pluginsdk.StateRefreshFunc { return func() (interface{}, string, error) { - resp, err := client.Get(ctx, vaultName, resourceGroup, "Azure", containerName, protectedItemName, "") + resp, err := client.Get(ctx, id, protecteditems.GetOperationOptions{}) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return resp, "NotFound", nil } - return resp, "Error", fmt.Errorf("making Read request on Azure Backup Protected VM %q (Resource Group %q): %+v", protectedItemName, resourceGroup, err) + return resp, "Error", fmt.Errorf("making Read request on %s: %+v", id, err) } return resp, "Found", nil } } -func expandDiskExclusion(d *pluginsdk.ResourceData) *backup.ExtendedProperties { +func expandDiskExclusion(d *pluginsdk.ResourceData) *protecteditems.ExtendedProperties { if v, ok := d.GetOk("include_disk_luns"); ok { diskLun := expandDiskLunList(v.(*pluginsdk.Set).List()) - return &backup.ExtendedProperties{ - DiskExclusionProperties: &backup.DiskExclusionProperties{ - DiskLunList: utils.ExpandInt32Slice(diskLun), + return &protecteditems.ExtendedProperties{ + DiskExclusionProperties: &protecteditems.DiskExclusionProperties{ + DiskLunList: utils.ExpandInt64Slice(diskLun), IsInclusionList: utils.Bool(true), }, } @@ -321,9 +327,9 @@ func expandDiskExclusion(d *pluginsdk.ResourceData) *backup.ExtendedProperties { if v, ok := d.GetOk("exclude_disk_luns"); ok { diskLun := expandDiskLunList(v.(*pluginsdk.Set).List()) - return &backup.ExtendedProperties{ - DiskExclusionProperties: &backup.DiskExclusionProperties{ - DiskLunList: utils.ExpandInt32Slice(diskLun), + return &protecteditems.ExtendedProperties{ + DiskExclusionProperties: &protecteditems.DiskExclusionProperties{ + DiskLunList: utils.ExpandInt64Slice(diskLun), IsInclusionList: utils.Bool(false), }, } diff --git a/internal/services/recoveryservices/backup_protected_vm_resource_test.go b/internal/services/recoveryservices/backup_protected_vm_resource_test.go index 6b84d1feb8a2..fd3862519d07 100644 --- a/internal/services/recoveryservices/backup_protected_vm_resource_test.go +++ b/internal/services/recoveryservices/backup_protected_vm_resource_test.go @@ -3,12 +3,12 @@ package recoveryservices_test import ( "context" "fmt" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems" "testing" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -202,17 +202,17 @@ func TestAccBackupProtectedVm_removeVM(t *testing.T) { } func (t BackupProtectedVmResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.ProtectedItemID(state.ID) + id, err := protecteditems.ParseProtectedItemID(state.ID) if err != nil { return nil, err } - resp, err := clients.RecoveryServices.ProtectedItemsClient.Get(ctx, id.VaultName, id.ResourceGroup, "Azure", id.ProtectionContainerName, id.Name, "") + resp, err := clients.RecoveryServices.ProtectedItemsClient.Get(ctx, *id, protecteditems.GetOperationOptions{}) if err != nil { return nil, fmt.Errorf("reading Recovery Service Protected VM (%s): %+v", id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (BackupProtectedVmResource) base(data acceptance.TestData) string { diff --git a/internal/services/recoveryservices/client/client.go b/internal/services/recoveryservices/client/client.go index ab87ef287ff3..87006f721647 100644 --- a/internal/services/recoveryservices/client/client.go +++ b/internal/services/recoveryservices/client/client.go @@ -3,8 +3,13 @@ package client import ( "github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup" // nolint: staticcheck "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2022-10-01/vaults" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems" "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupresourcestorageconfigsnoncrr" "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupresourcevaultconfigs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies" "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationfabrics" "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationnetworkmappings" "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationpolicies" @@ -19,12 +24,12 @@ import ( ) type Client struct { - ProtectableItemsClient *backup.ProtectableItemsClient - ProtectedItemsClient *backup.ProtectedItemsClient - ProtectedItemsGroupClient *backup.ProtectedItemsGroupClient - ProtectionPoliciesClient *backup.ProtectionPoliciesClient + ProtectableItemsClient *backupprotectableitems.BackupProtectableItemsClient + ProtectedItemsClient *protecteditems.ProtectedItemsClient + ProtectedItemsGroupClient *backupprotecteditems.BackupProtectedItemsClient + ProtectionPoliciesClient *protectionpolicies.ProtectionPoliciesClient ProtectionContainerOperationResultsClient *backup.ProtectionContainerOperationResultsClient - BackupProtectionContainersClient *backup.ProtectionContainersClient + BackupProtectionContainersClient *protectioncontainers.ProtectionContainersClient BackupOperationStatusesClient *backup.OperationStatusesClient BackupOperationResultsClient *backup.OperationResultsClient VaultsClient *vaults.VaultsClient @@ -58,19 +63,19 @@ func NewClient(o *common.ClientOptions) *Client { vaultCertificatesClient := azuresdkhacks.NewVaultCertificatesClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&vaultCertificatesClient.Client, o.ResourceManagerAuthorizer) - protectableItemsClient := backup.NewProtectableItemsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + protectableItemsClient := backupprotectableitems.NewBackupProtectableItemsClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&protectableItemsClient.Client, o.ResourceManagerAuthorizer) - protectedItemsClient := backup.NewProtectedItemsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + protectedItemsClient := protecteditems.NewProtectedItemsClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&protectedItemsClient.Client, o.ResourceManagerAuthorizer) - protectedItemsGroupClient := backup.NewProtectedItemsGroupClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + protectedItemsGroupClient := backupprotecteditems.NewBackupProtectedItemsClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&protectedItemsGroupClient.Client, o.ResourceManagerAuthorizer) - protectionPoliciesClient := backup.NewProtectionPoliciesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + protectionPoliciesClient := protectionpolicies.NewProtectionPoliciesClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&protectionPoliciesClient.Client, o.ResourceManagerAuthorizer) - backupProtectionContainersClient := backup.NewProtectionContainersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + backupProtectionContainersClient := protectioncontainers.NewProtectionContainersClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&backupProtectionContainersClient.Client, o.ResourceManagerAuthorizer) backupOperationStatusesClient := backup.NewOperationStatusesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/README.md new file mode 100644 index 000000000000..6ab196e3d1ce --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems` Documentation + +The `backupprotectableitems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2021-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems" +``` + + +### Client Initialization + +```go +client := backupprotectableitems.NewBackupProtectableItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupProtectableItemsClient.List` + +```go +ctx := context.TODO() +id := backupprotectableitems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, backupprotectableitems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupprotectableitems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/client.go new file mode 100644 index 000000000000..a30b2396b90e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/client.go @@ -0,0 +1,18 @@ +package backupprotectableitems + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupProtectableItemsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupProtectableItemsClientWithBaseURI(endpoint string) BackupProtectableItemsClient { + return BackupProtectableItemsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/constants.go new file mode 100644 index 000000000000..4707e9072d46 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/constants.go @@ -0,0 +1,105 @@ +package backupprotectableitems + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFileShareType string + +const ( + AzureFileShareTypeInvalid AzureFileShareType = "Invalid" + AzureFileShareTypeXSMB AzureFileShareType = "XSMB" + AzureFileShareTypeXSync AzureFileShareType = "XSync" +) + +func PossibleValuesForAzureFileShareType() []string { + return []string{ + string(AzureFileShareTypeInvalid), + string(AzureFileShareTypeXSMB), + string(AzureFileShareTypeXSync), + } +} + +func parseAzureFileShareType(input string) (*AzureFileShareType, error) { + vals := map[string]AzureFileShareType{ + "invalid": AzureFileShareTypeInvalid, + "xsmb": AzureFileShareTypeXSMB, + "xsync": AzureFileShareTypeXSync, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFileShareType(input) + return &out, nil +} + +type InquiryStatus string + +const ( + InquiryStatusFailed InquiryStatus = "Failed" + InquiryStatusInvalid InquiryStatus = "Invalid" + InquiryStatusSuccess InquiryStatus = "Success" +) + +func PossibleValuesForInquiryStatus() []string { + return []string{ + string(InquiryStatusFailed), + string(InquiryStatusInvalid), + string(InquiryStatusSuccess), + } +} + +func parseInquiryStatus(input string) (*InquiryStatus, error) { + vals := map[string]InquiryStatus{ + "failed": InquiryStatusFailed, + "invalid": InquiryStatusInvalid, + "success": InquiryStatusSuccess, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InquiryStatus(input) + return &out, nil +} + +type ProtectionStatus string + +const ( + ProtectionStatusInvalid ProtectionStatus = "Invalid" + ProtectionStatusNotProtected ProtectionStatus = "NotProtected" + ProtectionStatusProtected ProtectionStatus = "Protected" + ProtectionStatusProtecting ProtectionStatus = "Protecting" + ProtectionStatusProtectionFailed ProtectionStatus = "ProtectionFailed" +) + +func PossibleValuesForProtectionStatus() []string { + return []string{ + string(ProtectionStatusInvalid), + string(ProtectionStatusNotProtected), + string(ProtectionStatusProtected), + string(ProtectionStatusProtecting), + string(ProtectionStatusProtectionFailed), + } +} + +func parseProtectionStatus(input string) (*ProtectionStatus, error) { + vals := map[string]ProtectionStatus{ + "invalid": ProtectionStatusInvalid, + "notprotected": ProtectionStatusNotProtected, + "protected": ProtectionStatusProtected, + "protecting": ProtectionStatusProtecting, + "protectionfailed": ProtectionStatusProtectionFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionStatus(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/id_vault.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/id_vault.go new file mode 100644 index 000000000000..8b72edd8ba17 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/id_vault.go @@ -0,0 +1,127 @@ +package backupprotectableitems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := VaultId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := VaultId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/method_list_autorest.go new file mode 100644 index 000000000000..7e33743e4776 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupprotectableitems + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]WorkloadProtectableItemResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []WorkloadProtectableItemResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c BackupProtectableItemsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupProtectableItemsClient) preparerForList(ctx context.Context, id VaultId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupProtectableItems", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupProtectableItemsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c BackupProtectableItemsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []WorkloadProtectableItemResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupProtectableItemsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkloadProtectableItemResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupProtectableItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate WorkloadProtectableItemResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]WorkloadProtectableItemResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurefileshareprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurefileshareprotectableitem.go new file mode 100644 index 000000000000..609db8fe6419 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurefileshareprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureFileShareProtectableItem{} + +type AzureFileShareProtectableItem struct { + AzureFileShareType *AzureFileShareType `json:"azureFileShareType,omitempty"` + ParentContainerFabricId *string `json:"parentContainerFabricId,omitempty"` + ParentContainerFriendlyName *string `json:"parentContainerFriendlyName,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureFileShareProtectableItem{} + +func (s AzureFileShareProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "AzureFileShare" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go new file mode 100644 index 000000000000..14d4cde39da8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureIaaSClassicComputeVMProtectableItem{} + +type AzureIaaSClassicComputeVMProtectableItem struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMProtectableItem{} + +func (s AzureIaaSClassicComputeVMProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go new file mode 100644 index 000000000000..13c811a243b7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureIaaSComputeVMProtectableItem{} + +type AzureIaaSComputeVMProtectableItem struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureIaaSComputeVMProtectableItem{} + +func (s AzureIaaSComputeVMProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go new file mode 100644 index 000000000000..57722018c7d3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go @@ -0,0 +1,52 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadProtectableItem{} + +type AzureVMWorkloadProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadProtectableItem{} + +func (s AzureVMWorkloadProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "AzureVmWorkloadProtectableItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go new file mode 100644 index 000000000000..5b7fcf0cf9a7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go @@ -0,0 +1,52 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSAPAseSystemProtectableItem{} + +type AzureVMWorkloadSAPAseSystemProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPAseSystemProtectableItem{} + +func (s AzureVMWorkloadSAPAseSystemProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPAseSystemProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SAPAseSystem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go new file mode 100644 index 000000000000..07bea2135c37 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go @@ -0,0 +1,52 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSAPHanaDatabaseProtectableItem{} + +type AzureVMWorkloadSAPHanaDatabaseProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDatabaseProtectableItem{} + +func (s AzureVMWorkloadSAPHanaDatabaseProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDatabaseProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDatabaseProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDatabaseProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SAPHanaDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDatabaseProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go new file mode 100644 index 000000000000..7f69e4e091dc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go @@ -0,0 +1,52 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSAPHanaSystemProtectableItem{} + +type AzureVMWorkloadSAPHanaSystemProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaSystemProtectableItem{} + +func (s AzureVMWorkloadSAPHanaSystemProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaSystemProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaSystemProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaSystemProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SAPHanaSystem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaSystemProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go new file mode 100644 index 000000000000..c7ed4780435e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go @@ -0,0 +1,52 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSQLAvailabilityGroupProtectableItem{} + +type AzureVMWorkloadSQLAvailabilityGroupProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSQLAvailabilityGroupProtectableItem{} + +func (s AzureVMWorkloadSQLAvailabilityGroupProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLAvailabilityGroupProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLAvailabilityGroupProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLAvailabilityGroupProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SQLAvailabilityGroupContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLAvailabilityGroupProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go new file mode 100644 index 000000000000..9f094b48509f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go @@ -0,0 +1,52 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSQLDatabaseProtectableItem{} + +type AzureVMWorkloadSQLDatabaseProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSQLDatabaseProtectableItem{} + +func (s AzureVMWorkloadSQLDatabaseProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLDatabaseProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLDatabaseProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLDatabaseProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SQLDataBase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLDatabaseProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go new file mode 100644 index 000000000000..e58186604499 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go @@ -0,0 +1,52 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSQLInstanceProtectableItem{} + +type AzureVMWorkloadSQLInstanceProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSQLInstanceProtectableItem{} + +func (s AzureVMWorkloadSQLInstanceProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLInstanceProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLInstanceProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLInstanceProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SQLInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLInstanceProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_iaasvmprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_iaasvmprotectableitem.go new file mode 100644 index 000000000000..c05ab27225f6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_iaasvmprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = IaaSVMProtectableItem{} + +type IaaSVMProtectableItem struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = IaaSVMProtectableItem{} + +func (s IaaSVMProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper IaaSVMProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaaSVMProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaaSVMProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "IaaSVMProtectableItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaaSVMProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_prebackupvalidation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_prebackupvalidation.go new file mode 100644 index 000000000000..955dd612808c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_prebackupvalidation.go @@ -0,0 +1,10 @@ +package backupprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PreBackupValidation struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Status *InquiryStatus `json:"status,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_workloadprotectableitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_workloadprotectableitem.go new file mode 100644 index 000000000000..490e7e9f60e5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_workloadprotectableitem.go @@ -0,0 +1,128 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadProtectableItem interface { +} + +func unmarshalWorkloadProtectableItemImplementation(input []byte) (WorkloadProtectableItem, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling WorkloadProtectableItem into map[string]interface: %+v", err) + } + + value, ok := temp["protectableItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShare") { + var out AzureFileShareProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadProtectableItem") { + var out AzureVMWorkloadProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPAseSystem") { + var out AzureVMWorkloadSAPAseSystemProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPHanaDatabase") { + var out AzureVMWorkloadSAPHanaDatabaseProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDatabaseProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPHanaSystem") { + var out AzureVMWorkloadSAPHanaSystemProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaSystemProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLAvailabilityGroupContainer") { + var out AzureVMWorkloadSQLAvailabilityGroupProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLAvailabilityGroupProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLDataBase") { + var out AzureVMWorkloadSQLDatabaseProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLDatabaseProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLInstance") { + var out AzureVMWorkloadSQLInstanceProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLInstanceProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaaSVMProtectableItem") { + var out IaaSVMProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaaSVMProtectableItem: %+v", err) + } + return out, nil + } + + type RawWorkloadProtectableItemImpl struct { + Type string `json:"-"` + Values map[string]interface{} `json:"-"` + } + out := RawWorkloadProtectableItemImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_workloadprotectableitemresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_workloadprotectableitemresource.go new file mode 100644 index 000000000000..3f03589ca2d9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/model_workloadprotectableitemresource.go @@ -0,0 +1,50 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadProtectableItemResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties WorkloadProtectableItem `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &WorkloadProtectableItemResource{} + +func (s *WorkloadProtectableItemResource) UnmarshalJSON(bytes []byte) error { + type alias WorkloadProtectableItemResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into WorkloadProtectableItemResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling WorkloadProtectableItemResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalWorkloadProtectableItemImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'WorkloadProtectableItemResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/predicates.go new file mode 100644 index 000000000000..bb90f9edb611 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/predicates.go @@ -0,0 +1,37 @@ +package backupprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadProtectableItemResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkloadProtectableItemResourceOperationPredicate) Matches(input WorkloadProtectableItemResource) bool { + + if p.ETag != nil && (input.ETag == nil && *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/version.go new file mode 100644 index 000000000000..b616d36453a1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems/version.go @@ -0,0 +1,12 @@ +package backupprotectableitems + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupprotectableitems/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/README.md new file mode 100644 index 000000000000..1bca04d9e94c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems` Documentation + +The `backupprotecteditems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2021-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems" +``` + + +### Client Initialization + +```go +client := backupprotecteditems.NewBackupProtectedItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupProtectedItemsClient.List` + +```go +ctx := context.TODO() +id := backupprotecteditems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, backupprotecteditems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupprotecteditems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/client.go new file mode 100644 index 000000000000..7bb37dd5d36c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/client.go @@ -0,0 +1,18 @@ +package backupprotecteditems + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupProtectedItemsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupProtectedItemsClientWithBaseURI(endpoint string) BackupProtectedItemsClient { + return BackupProtectedItemsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/constants.go new file mode 100644 index 000000000000..c2929ba0aa43 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/constants.go @@ -0,0 +1,378 @@ +package backupprotecteditems + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type CreateMode string + +const ( + CreateModeDefault CreateMode = "Default" + CreateModeInvalid CreateMode = "Invalid" + CreateModeRecover CreateMode = "Recover" +) + +func PossibleValuesForCreateMode() []string { + return []string{ + string(CreateModeDefault), + string(CreateModeInvalid), + string(CreateModeRecover), + } +} + +func parseCreateMode(input string) (*CreateMode, error) { + vals := map[string]CreateMode{ + "default": CreateModeDefault, + "invalid": CreateModeInvalid, + "recover": CreateModeRecover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreateMode(input) + return &out, nil +} + +type DataSourceType string + +const ( + DataSourceTypeAzureFileShare DataSourceType = "AzureFileShare" + DataSourceTypeAzureSqlDb DataSourceType = "AzureSqlDb" + DataSourceTypeClient DataSourceType = "Client" + DataSourceTypeExchange DataSourceType = "Exchange" + DataSourceTypeFileFolder DataSourceType = "FileFolder" + DataSourceTypeGenericDataSource DataSourceType = "GenericDataSource" + DataSourceTypeInvalid DataSourceType = "Invalid" + DataSourceTypeSAPAseDatabase DataSourceType = "SAPAseDatabase" + DataSourceTypeSAPHanaDatabase DataSourceType = "SAPHanaDatabase" + DataSourceTypeSQLDB DataSourceType = "SQLDB" + DataSourceTypeSQLDataBase DataSourceType = "SQLDataBase" + DataSourceTypeSharepoint DataSourceType = "Sharepoint" + DataSourceTypeSystemState DataSourceType = "SystemState" + DataSourceTypeVM DataSourceType = "VM" + DataSourceTypeVMwareVM DataSourceType = "VMwareVM" +) + +func PossibleValuesForDataSourceType() []string { + return []string{ + string(DataSourceTypeAzureFileShare), + string(DataSourceTypeAzureSqlDb), + string(DataSourceTypeClient), + string(DataSourceTypeExchange), + string(DataSourceTypeFileFolder), + string(DataSourceTypeGenericDataSource), + string(DataSourceTypeInvalid), + string(DataSourceTypeSAPAseDatabase), + string(DataSourceTypeSAPHanaDatabase), + string(DataSourceTypeSQLDB), + string(DataSourceTypeSQLDataBase), + string(DataSourceTypeSharepoint), + string(DataSourceTypeSystemState), + string(DataSourceTypeVM), + string(DataSourceTypeVMwareVM), + } +} + +func parseDataSourceType(input string) (*DataSourceType, error) { + vals := map[string]DataSourceType{ + "azurefileshare": DataSourceTypeAzureFileShare, + "azuresqldb": DataSourceTypeAzureSqlDb, + "client": DataSourceTypeClient, + "exchange": DataSourceTypeExchange, + "filefolder": DataSourceTypeFileFolder, + "genericdatasource": DataSourceTypeGenericDataSource, + "invalid": DataSourceTypeInvalid, + "sapasedatabase": DataSourceTypeSAPAseDatabase, + "saphanadatabase": DataSourceTypeSAPHanaDatabase, + "sqldb": DataSourceTypeSQLDB, + "sqldatabase": DataSourceTypeSQLDataBase, + "sharepoint": DataSourceTypeSharepoint, + "systemstate": DataSourceTypeSystemState, + "vm": DataSourceTypeVM, + "vmwarevm": DataSourceTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSourceType(input) + return &out, nil +} + +type HealthStatus string + +const ( + HealthStatusActionRequired HealthStatus = "ActionRequired" + HealthStatusActionSuggested HealthStatus = "ActionSuggested" + HealthStatusInvalid HealthStatus = "Invalid" + HealthStatusPassed HealthStatus = "Passed" +) + +func PossibleValuesForHealthStatus() []string { + return []string{ + string(HealthStatusActionRequired), + string(HealthStatusActionSuggested), + string(HealthStatusInvalid), + string(HealthStatusPassed), + } +} + +func parseHealthStatus(input string) (*HealthStatus, error) { + vals := map[string]HealthStatus{ + "actionrequired": HealthStatusActionRequired, + "actionsuggested": HealthStatusActionSuggested, + "invalid": HealthStatusInvalid, + "passed": HealthStatusPassed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthStatus(input) + return &out, nil +} + +type LastBackupStatus string + +const ( + LastBackupStatusHealthy LastBackupStatus = "Healthy" + LastBackupStatusIRPending LastBackupStatus = "IRPending" + LastBackupStatusInvalid LastBackupStatus = "Invalid" + LastBackupStatusUnhealthy LastBackupStatus = "Unhealthy" +) + +func PossibleValuesForLastBackupStatus() []string { + return []string{ + string(LastBackupStatusHealthy), + string(LastBackupStatusIRPending), + string(LastBackupStatusInvalid), + string(LastBackupStatusUnhealthy), + } +} + +func parseLastBackupStatus(input string) (*LastBackupStatus, error) { + vals := map[string]LastBackupStatus{ + "healthy": LastBackupStatusHealthy, + "irpending": LastBackupStatusIRPending, + "invalid": LastBackupStatusInvalid, + "unhealthy": LastBackupStatusUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LastBackupStatus(input) + return &out, nil +} + +type ProtectedItemHealthStatus string + +const ( + ProtectedItemHealthStatusHealthy ProtectedItemHealthStatus = "Healthy" + ProtectedItemHealthStatusIRPending ProtectedItemHealthStatus = "IRPending" + ProtectedItemHealthStatusInvalid ProtectedItemHealthStatus = "Invalid" + ProtectedItemHealthStatusNotReachable ProtectedItemHealthStatus = "NotReachable" + ProtectedItemHealthStatusUnhealthy ProtectedItemHealthStatus = "Unhealthy" +) + +func PossibleValuesForProtectedItemHealthStatus() []string { + return []string{ + string(ProtectedItemHealthStatusHealthy), + string(ProtectedItemHealthStatusIRPending), + string(ProtectedItemHealthStatusInvalid), + string(ProtectedItemHealthStatusNotReachable), + string(ProtectedItemHealthStatusUnhealthy), + } +} + +func parseProtectedItemHealthStatus(input string) (*ProtectedItemHealthStatus, error) { + vals := map[string]ProtectedItemHealthStatus{ + "healthy": ProtectedItemHealthStatusHealthy, + "irpending": ProtectedItemHealthStatusIRPending, + "invalid": ProtectedItemHealthStatusInvalid, + "notreachable": ProtectedItemHealthStatusNotReachable, + "unhealthy": ProtectedItemHealthStatusUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectedItemHealthStatus(input) + return &out, nil +} + +type ProtectedItemState string + +const ( + ProtectedItemStateIRPending ProtectedItemState = "IRPending" + ProtectedItemStateInvalid ProtectedItemState = "Invalid" + ProtectedItemStateProtected ProtectedItemState = "Protected" + ProtectedItemStateProtectionError ProtectedItemState = "ProtectionError" + ProtectedItemStateProtectionPaused ProtectedItemState = "ProtectionPaused" + ProtectedItemStateProtectionStopped ProtectedItemState = "ProtectionStopped" +) + +func PossibleValuesForProtectedItemState() []string { + return []string{ + string(ProtectedItemStateIRPending), + string(ProtectedItemStateInvalid), + string(ProtectedItemStateProtected), + string(ProtectedItemStateProtectionError), + string(ProtectedItemStateProtectionPaused), + string(ProtectedItemStateProtectionStopped), + } +} + +func parseProtectedItemState(input string) (*ProtectedItemState, error) { + vals := map[string]ProtectedItemState{ + "irpending": ProtectedItemStateIRPending, + "invalid": ProtectedItemStateInvalid, + "protected": ProtectedItemStateProtected, + "protectionerror": ProtectedItemStateProtectionError, + "protectionpaused": ProtectedItemStateProtectionPaused, + "protectionstopped": ProtectedItemStateProtectionStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectedItemState(input) + return &out, nil +} + +type ProtectionState string + +const ( + ProtectionStateIRPending ProtectionState = "IRPending" + ProtectionStateInvalid ProtectionState = "Invalid" + ProtectionStateProtected ProtectionState = "Protected" + ProtectionStateProtectionError ProtectionState = "ProtectionError" + ProtectionStateProtectionPaused ProtectionState = "ProtectionPaused" + ProtectionStateProtectionStopped ProtectionState = "ProtectionStopped" +) + +func PossibleValuesForProtectionState() []string { + return []string{ + string(ProtectionStateIRPending), + string(ProtectionStateInvalid), + string(ProtectionStateProtected), + string(ProtectionStateProtectionError), + string(ProtectionStateProtectionPaused), + string(ProtectionStateProtectionStopped), + } +} + +func parseProtectionState(input string) (*ProtectionState, error) { + vals := map[string]ProtectionState{ + "irpending": ProtectionStateIRPending, + "invalid": ProtectionStateInvalid, + "protected": ProtectionStateProtected, + "protectionerror": ProtectionStateProtectionError, + "protectionpaused": ProtectionStateProtectionPaused, + "protectionstopped": ProtectionStateProtectionStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionState(input) + return &out, nil +} + +type ResourceHealthStatus string + +const ( + ResourceHealthStatusHealthy ResourceHealthStatus = "Healthy" + ResourceHealthStatusInvalid ResourceHealthStatus = "Invalid" + ResourceHealthStatusPersistentDegraded ResourceHealthStatus = "PersistentDegraded" + ResourceHealthStatusPersistentUnhealthy ResourceHealthStatus = "PersistentUnhealthy" + ResourceHealthStatusTransientDegraded ResourceHealthStatus = "TransientDegraded" + ResourceHealthStatusTransientUnhealthy ResourceHealthStatus = "TransientUnhealthy" +) + +func PossibleValuesForResourceHealthStatus() []string { + return []string{ + string(ResourceHealthStatusHealthy), + string(ResourceHealthStatusInvalid), + string(ResourceHealthStatusPersistentDegraded), + string(ResourceHealthStatusPersistentUnhealthy), + string(ResourceHealthStatusTransientDegraded), + string(ResourceHealthStatusTransientUnhealthy), + } +} + +func parseResourceHealthStatus(input string) (*ResourceHealthStatus, error) { + vals := map[string]ResourceHealthStatus{ + "healthy": ResourceHealthStatusHealthy, + "invalid": ResourceHealthStatusInvalid, + "persistentdegraded": ResourceHealthStatusPersistentDegraded, + "persistentunhealthy": ResourceHealthStatusPersistentUnhealthy, + "transientdegraded": ResourceHealthStatusTransientDegraded, + "transientunhealthy": ResourceHealthStatusTransientUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceHealthStatus(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/id_vault.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/id_vault.go new file mode 100644 index 000000000000..f8fbd5332a7d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/id_vault.go @@ -0,0 +1,127 @@ +package backupprotecteditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := VaultId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := VaultId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/method_list_autorest.go new file mode 100644 index 000000000000..5b5c8cd79c12 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupprotecteditems + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]ProtectedItemResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ProtectedItemResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c BackupProtectedItemsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupProtectedItemsClient) preparerForList(ctx context.Context, id VaultId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupProtectedItems", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupProtectedItemsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c BackupProtectedItemsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ProtectedItemResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupProtectedItemsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ProtectedItemResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupProtectedItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ProtectedItemResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ProtectedItemResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurefileshareprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurefileshareprotecteditem.go new file mode 100644 index 000000000000..a0e3c902cc8e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurefileshareprotecteditem.go @@ -0,0 +1,90 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureFileshareProtectedItem{} + +type AzureFileshareProtectedItem struct { + ExtendedInfo *AzureFileshareProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureFileshareProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureFileshareProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureFileshareProtectedItem{} + +func (s AzureFileshareProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureFileshareProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileshareProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileshareProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureFileShareProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileshareProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go new file mode 100644 index 000000000000..784dbda1d5d9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go @@ -0,0 +1,42 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFileshareProtectedItemExtendedInfo struct { + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` + ResourceState *string `json:"resourceState,omitempty"` + ResourceStateSyncTime *string `json:"resourceStateSyncTime,omitempty"` +} + +func (o *AzureFileshareProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureFileshareProtectedItemExtendedInfo) GetResourceStateSyncTimeAsTime() (*time.Time, error) { + if o.ResourceStateSyncTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResourceStateSyncTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItemExtendedInfo) SetResourceStateSyncTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResourceStateSyncTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go new file mode 100644 index 000000000000..137e4f310b70 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go @@ -0,0 +1,95 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSClassicComputeVMProtectedItem{} + +type AzureIaaSClassicComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMProtectedItem{} + +func (s AzureIaaSClassicComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go new file mode 100644 index 000000000000..c41ef520e893 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go @@ -0,0 +1,95 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSComputeVMProtectedItem{} + +type AzureIaaSComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSComputeVMProtectedItem{} + +func (s AzureIaaSComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasvmprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasvmprotecteditem.go new file mode 100644 index 000000000000..f897de06c999 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasvmprotecteditem.go @@ -0,0 +1,95 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSVMProtectedItem{} + +type AzureIaaSVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSVMProtectedItem{} + +func (s AzureIaaSVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureIaaSVMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go new file mode 100644 index 000000000000..f9bd89ad856e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go @@ -0,0 +1,67 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMProtectedItemExtendedInfo struct { + NewestRecoveryPointInArchive *string `json:"newestRecoveryPointInArchive,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OldestRecoveryPointInArchive *string `json:"oldestRecoveryPointInArchive,omitempty"` + OldestRecoveryPointInVault *string `json:"oldestRecoveryPointInVault,omitempty"` + PolicyInconsistent *bool `json:"policyInconsistent,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetNewestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.NewestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NewestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetNewestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NewestRecoveryPointInArchive = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInArchive = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointInVaultAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInVault == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInVault, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointInVaultAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInVault = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azuresqlprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azuresqlprotecteditem.go new file mode 100644 index 000000000000..f1c2d84b99cc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azuresqlprotecteditem.go @@ -0,0 +1,86 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureSqlProtectedItem{} + +type AzureSqlProtectedItem struct { + ExtendedInfo *AzureSqlProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureSqlProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureSqlProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureSqlProtectedItem{} + +func (s AzureSqlProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Sql/servers/databases" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go new file mode 100644 index 000000000000..1f95cebc98c3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go @@ -0,0 +1,28 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureSqlProtectedItemExtendedInfo struct { + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureSqlProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go new file mode 100644 index 000000000000..87e661d0cd37 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go @@ -0,0 +1,96 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadProtectedItem{} + +type AzureVMWorkloadProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadProtectedItem{} + +func (s AzureVMWorkloadProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go new file mode 100644 index 000000000000..4ad1e1588476 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go @@ -0,0 +1,68 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureVMWorkloadProtectedItemExtendedInfo struct { + NewestRecoveryPointInArchive *string `json:"newestRecoveryPointInArchive,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OldestRecoveryPointInArchive *string `json:"oldestRecoveryPointInArchive,omitempty"` + OldestRecoveryPointInVault *string `json:"oldestRecoveryPointInVault,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryModel *string `json:"recoveryModel,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetNewestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.NewestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NewestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetNewestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NewestRecoveryPointInArchive = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInArchive = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointInVaultAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInVault == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInVault, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointInVaultAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInVault = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go new file mode 100644 index 000000000000..0a6144e4e993 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go @@ -0,0 +1,96 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSAPAseDatabaseProtectedItem{} + +type AzureVMWorkloadSAPAseDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPAseDatabaseProtectedItem{} + +func (s AzureVMWorkloadSAPAseDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPAseDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSAPAseDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go new file mode 100644 index 000000000000..de982e62b4e0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go @@ -0,0 +1,96 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSAPHanaDatabaseProtectedItem{} + +type AzureVMWorkloadSAPHanaDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDatabaseProtectedItem{} + +func (s AzureVMWorkloadSAPHanaDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSAPHanaDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go new file mode 100644 index 000000000000..b4f03d1cbb43 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go @@ -0,0 +1,96 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSQLDatabaseProtectedItem{} + +type AzureVMWorkloadSQLDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSQLDatabaseProtectedItem{} + +func (s AzureVMWorkloadSQLDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSQLDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_diskexclusionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_diskexclusionproperties.go new file mode 100644 index 000000000000..f12fc0030e20 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_diskexclusionproperties.go @@ -0,0 +1,9 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskExclusionProperties struct { + DiskLunList *[]int64 `json:"diskLunList,omitempty"` + IsInclusionList *bool `json:"isInclusionList,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_dpmprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_dpmprotecteditem.go new file mode 100644 index 000000000000..e5fb7fff2d27 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_dpmprotecteditem.go @@ -0,0 +1,87 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = DPMProtectedItem{} + +type DPMProtectedItem struct { + BackupEngineName *string `json:"backupEngineName,omitempty"` + ExtendedInfo *DPMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *DPMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *DPMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = DPMProtectedItem{} + +func (s DPMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper DPMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DPMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DPMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "DPMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DPMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go new file mode 100644 index 000000000000..c28c138b06eb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go @@ -0,0 +1,75 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DPMProtectedItemExtendedInfo struct { + DiskStorageUsedInBytes *string `json:"diskStorageUsedInBytes,omitempty"` + IsCollocated *bool `json:"isCollocated,omitempty"` + IsPresentOnCloud *bool `json:"isPresentOnCloud,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OnPremiseLatestRecoveryPoint *string `json:"onPremiseLatestRecoveryPoint,omitempty"` + OnPremiseOldestRecoveryPoint *string `json:"onPremiseOldestRecoveryPoint,omitempty"` + OnPremiseRecoveryPointCount *int64 `json:"onPremiseRecoveryPointCount,omitempty"` + ProtectableObjectLoadPath *map[string]string `json:"protectableObjectLoadPath,omitempty"` + Protected *bool `json:"protected,omitempty"` + ProtectionGroupName *string `json:"protectionGroupName,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` + TotalDiskStorageSizeInBytes *string `json:"totalDiskStorageSizeInBytes,omitempty"` +} + +func (o *DPMProtectedItemExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOnPremiseLatestRecoveryPointAsTime() (*time.Time, error) { + if o.OnPremiseLatestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OnPremiseLatestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOnPremiseLatestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OnPremiseLatestRecoveryPoint = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOnPremiseOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OnPremiseOldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OnPremiseOldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOnPremiseOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OnPremiseOldestRecoveryPoint = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_errordetail.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_errordetail.go new file mode 100644 index 000000000000..c55cc388bf95 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_errordetail.go @@ -0,0 +1,10 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_extendedproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_extendedproperties.go new file mode 100644 index 000000000000..bd52e28b60ee --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_extendedproperties.go @@ -0,0 +1,9 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedProperties struct { + DiskExclusionProperties *DiskExclusionProperties `json:"diskExclusionProperties,omitempty"` + LinuxVMApplicationName *string `json:"linuxVmApplicationName,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_genericprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_genericprotecteditem.go new file mode 100644 index 000000000000..834ebf0c1e6b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_genericprotecteditem.go @@ -0,0 +1,89 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = GenericProtectedItem{} + +type GenericProtectedItem struct { + FabricName *string `json:"fabricName,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + ProtectedItemId *int64 `json:"protectedItemId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + SourceAssociations *map[string]string `json:"sourceAssociations,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *GenericProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *GenericProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = GenericProtectedItem{} + +func (s GenericProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper GenericProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "GenericProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_kpiresourcehealthdetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_kpiresourcehealthdetails.go new file mode 100644 index 000000000000..42a11e535b9e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_kpiresourcehealthdetails.go @@ -0,0 +1,9 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KPIResourceHealthDetails struct { + ResourceHealthDetails *[]ResourceHealthDetails `json:"resourceHealthDetails,omitempty"` + ResourceHealthStatus *ResourceHealthStatus `json:"resourceHealthStatus,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_mabfilefolderprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_mabfilefolderprotecteditem.go new file mode 100644 index 000000000000..0c7384b7fbdd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_mabfilefolderprotecteditem.go @@ -0,0 +1,90 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = MabFileFolderProtectedItem{} + +type MabFileFolderProtectedItem struct { + ComputerName *string `json:"computerName,omitempty"` + DeferredDeleteSyncTimeInUTC *int64 `json:"deferredDeleteSyncTimeInUTC,omitempty"` + ExtendedInfo *MabFileFolderProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *MabFileFolderProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *MabFileFolderProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = MabFileFolderProtectedItem{} + +func (s MabFileFolderProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper MabFileFolderProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabFileFolderProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabFileFolderProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "MabFileFolderProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabFileFolderProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go new file mode 100644 index 000000000000..30f88b5c2acd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go @@ -0,0 +1,40 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabFileFolderProtectedItemExtendedInfo struct { + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *MabFileFolderProtectedItemExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItemExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} + +func (o *MabFileFolderProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_protecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_protecteditem.go new file mode 100644 index 000000000000..582156d3e68b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_protecteditem.go @@ -0,0 +1,136 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItem interface { +} + +func unmarshalProtectedItemImplementation(input []byte) (ProtectedItem, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectedItem into map[string]interface: %+v", err) + } + + value, ok := temp["protectedItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareProtectedItem") { + var out AzureFileshareProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileshareProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaaSVMProtectedItem") { + var out AzureIaaSVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Sql/servers/databases") { + var out AzureSqlProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadProtectedItem") { + var out AzureVMWorkloadProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPAseDatabase") { + var out AzureVMWorkloadSAPAseDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPHanaDatabase") { + var out AzureVMWorkloadSAPHanaDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSQLDatabase") { + var out AzureVMWorkloadSQLDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DPMProtectedItem") { + var out DPMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DPMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericProtectedItem") { + var out GenericProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MabFileFolderProtectedItem") { + var out MabFileFolderProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabFileFolderProtectedItem: %+v", err) + } + return out, nil + } + + type RawProtectedItemImpl struct { + Type string `json:"-"` + Values map[string]interface{} `json:"-"` + } + out := RawProtectedItemImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_protecteditemresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_protecteditemresource.go new file mode 100644 index 000000000000..cf1da7db76fa --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_protecteditemresource.go @@ -0,0 +1,50 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItemResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectedItem `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectedItemResource{} + +func (s *ProtectedItemResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectedItemResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectedItemResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectedItemResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectedItemImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectedItemResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_resourcehealthdetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_resourcehealthdetails.go new file mode 100644 index 000000000000..34cb35fbf15a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/model_resourcehealthdetails.go @@ -0,0 +1,11 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthDetails struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/predicates.go new file mode 100644 index 000000000000..5a0d1c82b794 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/predicates.go @@ -0,0 +1,37 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItemResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectedItemResourceOperationPredicate) Matches(input ProtectedItemResource) bool { + + if p.ETag != nil && (input.ETag == nil && *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/version.go new file mode 100644 index 000000000000..3eeb5655f214 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems/version.go @@ -0,0 +1,12 @@ +package backupprotecteditems + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupprotecteditems/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/README.md new file mode 100644 index 000000000000..5c3827217bb7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/README.md @@ -0,0 +1,73 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems` Documentation + +The `protecteditems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2021-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems" +``` + + +### Client Initialization + +```go +client := protecteditems.NewProtectedItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectedItemsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := protecteditems.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +payload := protecteditems.ProtectedItemResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectedItemsClient.Delete` + +```go +ctx := context.TODO() +id := protecteditems.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectedItemsClient.Get` + +```go +ctx := context.TODO() +id := protecteditems.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +read, err := client.Get(ctx, id, protecteditems.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/client.go new file mode 100644 index 000000000000..6843a00f823f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/client.go @@ -0,0 +1,18 @@ +package protecteditems + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItemsClient struct { + Client autorest.Client + baseUri string +} + +func NewProtectedItemsClientWithBaseURI(endpoint string) ProtectedItemsClient { + return ProtectedItemsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/constants.go new file mode 100644 index 000000000000..04ddf8ff66e6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/constants.go @@ -0,0 +1,378 @@ +package protecteditems + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type CreateMode string + +const ( + CreateModeDefault CreateMode = "Default" + CreateModeInvalid CreateMode = "Invalid" + CreateModeRecover CreateMode = "Recover" +) + +func PossibleValuesForCreateMode() []string { + return []string{ + string(CreateModeDefault), + string(CreateModeInvalid), + string(CreateModeRecover), + } +} + +func parseCreateMode(input string) (*CreateMode, error) { + vals := map[string]CreateMode{ + "default": CreateModeDefault, + "invalid": CreateModeInvalid, + "recover": CreateModeRecover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreateMode(input) + return &out, nil +} + +type DataSourceType string + +const ( + DataSourceTypeAzureFileShare DataSourceType = "AzureFileShare" + DataSourceTypeAzureSqlDb DataSourceType = "AzureSqlDb" + DataSourceTypeClient DataSourceType = "Client" + DataSourceTypeExchange DataSourceType = "Exchange" + DataSourceTypeFileFolder DataSourceType = "FileFolder" + DataSourceTypeGenericDataSource DataSourceType = "GenericDataSource" + DataSourceTypeInvalid DataSourceType = "Invalid" + DataSourceTypeSAPAseDatabase DataSourceType = "SAPAseDatabase" + DataSourceTypeSAPHanaDatabase DataSourceType = "SAPHanaDatabase" + DataSourceTypeSQLDB DataSourceType = "SQLDB" + DataSourceTypeSQLDataBase DataSourceType = "SQLDataBase" + DataSourceTypeSharepoint DataSourceType = "Sharepoint" + DataSourceTypeSystemState DataSourceType = "SystemState" + DataSourceTypeVM DataSourceType = "VM" + DataSourceTypeVMwareVM DataSourceType = "VMwareVM" +) + +func PossibleValuesForDataSourceType() []string { + return []string{ + string(DataSourceTypeAzureFileShare), + string(DataSourceTypeAzureSqlDb), + string(DataSourceTypeClient), + string(DataSourceTypeExchange), + string(DataSourceTypeFileFolder), + string(DataSourceTypeGenericDataSource), + string(DataSourceTypeInvalid), + string(DataSourceTypeSAPAseDatabase), + string(DataSourceTypeSAPHanaDatabase), + string(DataSourceTypeSQLDB), + string(DataSourceTypeSQLDataBase), + string(DataSourceTypeSharepoint), + string(DataSourceTypeSystemState), + string(DataSourceTypeVM), + string(DataSourceTypeVMwareVM), + } +} + +func parseDataSourceType(input string) (*DataSourceType, error) { + vals := map[string]DataSourceType{ + "azurefileshare": DataSourceTypeAzureFileShare, + "azuresqldb": DataSourceTypeAzureSqlDb, + "client": DataSourceTypeClient, + "exchange": DataSourceTypeExchange, + "filefolder": DataSourceTypeFileFolder, + "genericdatasource": DataSourceTypeGenericDataSource, + "invalid": DataSourceTypeInvalid, + "sapasedatabase": DataSourceTypeSAPAseDatabase, + "saphanadatabase": DataSourceTypeSAPHanaDatabase, + "sqldb": DataSourceTypeSQLDB, + "sqldatabase": DataSourceTypeSQLDataBase, + "sharepoint": DataSourceTypeSharepoint, + "systemstate": DataSourceTypeSystemState, + "vm": DataSourceTypeVM, + "vmwarevm": DataSourceTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSourceType(input) + return &out, nil +} + +type HealthStatus string + +const ( + HealthStatusActionRequired HealthStatus = "ActionRequired" + HealthStatusActionSuggested HealthStatus = "ActionSuggested" + HealthStatusInvalid HealthStatus = "Invalid" + HealthStatusPassed HealthStatus = "Passed" +) + +func PossibleValuesForHealthStatus() []string { + return []string{ + string(HealthStatusActionRequired), + string(HealthStatusActionSuggested), + string(HealthStatusInvalid), + string(HealthStatusPassed), + } +} + +func parseHealthStatus(input string) (*HealthStatus, error) { + vals := map[string]HealthStatus{ + "actionrequired": HealthStatusActionRequired, + "actionsuggested": HealthStatusActionSuggested, + "invalid": HealthStatusInvalid, + "passed": HealthStatusPassed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthStatus(input) + return &out, nil +} + +type LastBackupStatus string + +const ( + LastBackupStatusHealthy LastBackupStatus = "Healthy" + LastBackupStatusIRPending LastBackupStatus = "IRPending" + LastBackupStatusInvalid LastBackupStatus = "Invalid" + LastBackupStatusUnhealthy LastBackupStatus = "Unhealthy" +) + +func PossibleValuesForLastBackupStatus() []string { + return []string{ + string(LastBackupStatusHealthy), + string(LastBackupStatusIRPending), + string(LastBackupStatusInvalid), + string(LastBackupStatusUnhealthy), + } +} + +func parseLastBackupStatus(input string) (*LastBackupStatus, error) { + vals := map[string]LastBackupStatus{ + "healthy": LastBackupStatusHealthy, + "irpending": LastBackupStatusIRPending, + "invalid": LastBackupStatusInvalid, + "unhealthy": LastBackupStatusUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LastBackupStatus(input) + return &out, nil +} + +type ProtectedItemHealthStatus string + +const ( + ProtectedItemHealthStatusHealthy ProtectedItemHealthStatus = "Healthy" + ProtectedItemHealthStatusIRPending ProtectedItemHealthStatus = "IRPending" + ProtectedItemHealthStatusInvalid ProtectedItemHealthStatus = "Invalid" + ProtectedItemHealthStatusNotReachable ProtectedItemHealthStatus = "NotReachable" + ProtectedItemHealthStatusUnhealthy ProtectedItemHealthStatus = "Unhealthy" +) + +func PossibleValuesForProtectedItemHealthStatus() []string { + return []string{ + string(ProtectedItemHealthStatusHealthy), + string(ProtectedItemHealthStatusIRPending), + string(ProtectedItemHealthStatusInvalid), + string(ProtectedItemHealthStatusNotReachable), + string(ProtectedItemHealthStatusUnhealthy), + } +} + +func parseProtectedItemHealthStatus(input string) (*ProtectedItemHealthStatus, error) { + vals := map[string]ProtectedItemHealthStatus{ + "healthy": ProtectedItemHealthStatusHealthy, + "irpending": ProtectedItemHealthStatusIRPending, + "invalid": ProtectedItemHealthStatusInvalid, + "notreachable": ProtectedItemHealthStatusNotReachable, + "unhealthy": ProtectedItemHealthStatusUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectedItemHealthStatus(input) + return &out, nil +} + +type ProtectedItemState string + +const ( + ProtectedItemStateIRPending ProtectedItemState = "IRPending" + ProtectedItemStateInvalid ProtectedItemState = "Invalid" + ProtectedItemStateProtected ProtectedItemState = "Protected" + ProtectedItemStateProtectionError ProtectedItemState = "ProtectionError" + ProtectedItemStateProtectionPaused ProtectedItemState = "ProtectionPaused" + ProtectedItemStateProtectionStopped ProtectedItemState = "ProtectionStopped" +) + +func PossibleValuesForProtectedItemState() []string { + return []string{ + string(ProtectedItemStateIRPending), + string(ProtectedItemStateInvalid), + string(ProtectedItemStateProtected), + string(ProtectedItemStateProtectionError), + string(ProtectedItemStateProtectionPaused), + string(ProtectedItemStateProtectionStopped), + } +} + +func parseProtectedItemState(input string) (*ProtectedItemState, error) { + vals := map[string]ProtectedItemState{ + "irpending": ProtectedItemStateIRPending, + "invalid": ProtectedItemStateInvalid, + "protected": ProtectedItemStateProtected, + "protectionerror": ProtectedItemStateProtectionError, + "protectionpaused": ProtectedItemStateProtectionPaused, + "protectionstopped": ProtectedItemStateProtectionStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectedItemState(input) + return &out, nil +} + +type ProtectionState string + +const ( + ProtectionStateIRPending ProtectionState = "IRPending" + ProtectionStateInvalid ProtectionState = "Invalid" + ProtectionStateProtected ProtectionState = "Protected" + ProtectionStateProtectionError ProtectionState = "ProtectionError" + ProtectionStateProtectionPaused ProtectionState = "ProtectionPaused" + ProtectionStateProtectionStopped ProtectionState = "ProtectionStopped" +) + +func PossibleValuesForProtectionState() []string { + return []string{ + string(ProtectionStateIRPending), + string(ProtectionStateInvalid), + string(ProtectionStateProtected), + string(ProtectionStateProtectionError), + string(ProtectionStateProtectionPaused), + string(ProtectionStateProtectionStopped), + } +} + +func parseProtectionState(input string) (*ProtectionState, error) { + vals := map[string]ProtectionState{ + "irpending": ProtectionStateIRPending, + "invalid": ProtectionStateInvalid, + "protected": ProtectionStateProtected, + "protectionerror": ProtectionStateProtectionError, + "protectionpaused": ProtectionStateProtectionPaused, + "protectionstopped": ProtectionStateProtectionStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionState(input) + return &out, nil +} + +type ResourceHealthStatus string + +const ( + ResourceHealthStatusHealthy ResourceHealthStatus = "Healthy" + ResourceHealthStatusInvalid ResourceHealthStatus = "Invalid" + ResourceHealthStatusPersistentDegraded ResourceHealthStatus = "PersistentDegraded" + ResourceHealthStatusPersistentUnhealthy ResourceHealthStatus = "PersistentUnhealthy" + ResourceHealthStatusTransientDegraded ResourceHealthStatus = "TransientDegraded" + ResourceHealthStatusTransientUnhealthy ResourceHealthStatus = "TransientUnhealthy" +) + +func PossibleValuesForResourceHealthStatus() []string { + return []string{ + string(ResourceHealthStatusHealthy), + string(ResourceHealthStatusInvalid), + string(ResourceHealthStatusPersistentDegraded), + string(ResourceHealthStatusPersistentUnhealthy), + string(ResourceHealthStatusTransientDegraded), + string(ResourceHealthStatusTransientUnhealthy), + } +} + +func parseResourceHealthStatus(input string) (*ResourceHealthStatus, error) { + vals := map[string]ResourceHealthStatus{ + "healthy": ResourceHealthStatusHealthy, + "invalid": ResourceHealthStatusInvalid, + "persistentdegraded": ResourceHealthStatusPersistentDegraded, + "persistentunhealthy": ResourceHealthStatusPersistentUnhealthy, + "transientdegraded": ResourceHealthStatusTransientDegraded, + "transientunhealthy": ResourceHealthStatusTransientUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceHealthStatus(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/id_protecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/id_protecteditem.go new file mode 100644 index 000000000000..998386b144af --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/id_protecteditem.go @@ -0,0 +1,166 @@ +package protecteditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = ProtectedItemId{} + +// ProtectedItemId is a struct representing the Resource ID for a Protected Item +type ProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string +} + +// NewProtectedItemID returns a new ProtectedItemId struct +func NewProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string) ProtectedItemId { + return ProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + } +} + +// ParseProtectedItemID parses 'input' into a ProtectedItemId +func ParseProtectedItemID(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(ProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProtectedItemId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + if id.BackupFabricName, ok = parsed.Parsed["backupFabricName"]; !ok { + return nil, fmt.Errorf("the segment 'backupFabricName' was not found in the resource id %q", input) + } + + if id.ProtectionContainerName, ok = parsed.Parsed["protectionContainerName"]; !ok { + return nil, fmt.Errorf("the segment 'protectionContainerName' was not found in the resource id %q", input) + } + + if id.ProtectedItemName, ok = parsed.Parsed["protectedItemName"]; !ok { + return nil, fmt.Errorf("the segment 'protectedItemName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseProtectedItemIDInsensitively parses 'input' case-insensitively into a ProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseProtectedItemIDInsensitively(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(ProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProtectedItemId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + if id.BackupFabricName, ok = parsed.Parsed["backupFabricName"]; !ok { + return nil, fmt.Errorf("the segment 'backupFabricName' was not found in the resource id %q", input) + } + + if id.ProtectionContainerName, ok = parsed.Parsed["protectionContainerName"]; !ok { + return nil, fmt.Errorf("the segment 'protectionContainerName' was not found in the resource id %q", input) + } + + if id.ProtectedItemName, ok = parsed.Parsed["protectedItemName"]; !ok { + return nil, fmt.Errorf("the segment 'protectedItemName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateProtectedItemID checks that 'input' can be parsed as a Protected Item ID +func ValidateProtectedItemID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Protected Item ID +func (id ProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Protected Item ID +func (id ProtectedItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + } +} + +// String returns a human-readable description of this Protected Item ID +func (id ProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + } + return fmt.Sprintf("Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_createorupdate_autorest.go new file mode 100644 index 000000000000..22eeaf22b56c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_createorupdate_autorest.go @@ -0,0 +1,69 @@ +package protecteditems + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *ProtectedItemResource +} + +// CreateOrUpdate ... +func (c ProtectedItemsClient) CreateOrUpdate(ctx context.Context, id ProtectedItemId, input ProtectedItemResource) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c ProtectedItemsClient) preparerForCreateOrUpdate(ctx context.Context, id ProtectedItemId, input ProtectedItemResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c ProtectedItemsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_delete_autorest.go new file mode 100644 index 000000000000..ed0ba3ec7a78 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_delete_autorest.go @@ -0,0 +1,66 @@ +package protecteditems + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response +} + +// Delete ... +func (c ProtectedItemsClient) Delete(ctx context.Context, id ProtectedItemId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c ProtectedItemsClient) preparerForDelete(ctx context.Context, id ProtectedItemId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c ProtectedItemsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_get_autorest.go new file mode 100644 index 000000000000..feb41aa7dcb5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/method_get_autorest.go @@ -0,0 +1,97 @@ +package protecteditems + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *ProtectedItemResource +} + +type GetOperationOptions struct { + Filter *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o GetOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// Get ... +func (c ProtectedItemsClient) Get(ctx context.Context, id ProtectedItemId, options GetOperationOptions) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ProtectedItemsClient) preparerForGet(ctx context.Context, id ProtectedItemId, options GetOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ProtectedItemsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurefileshareprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurefileshareprotecteditem.go new file mode 100644 index 000000000000..1030e92820f2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurefileshareprotecteditem.go @@ -0,0 +1,90 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureFileshareProtectedItem{} + +type AzureFileshareProtectedItem struct { + ExtendedInfo *AzureFileshareProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureFileshareProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureFileshareProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureFileshareProtectedItem{} + +func (s AzureFileshareProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureFileshareProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileshareProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileshareProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureFileShareProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileshareProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go new file mode 100644 index 000000000000..f3ee3ce37c0f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go @@ -0,0 +1,42 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFileshareProtectedItemExtendedInfo struct { + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` + ResourceState *string `json:"resourceState,omitempty"` + ResourceStateSyncTime *string `json:"resourceStateSyncTime,omitempty"` +} + +func (o *AzureFileshareProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureFileshareProtectedItemExtendedInfo) GetResourceStateSyncTimeAsTime() (*time.Time, error) { + if o.ResourceStateSyncTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResourceStateSyncTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItemExtendedInfo) SetResourceStateSyncTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResourceStateSyncTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go new file mode 100644 index 000000000000..58c9daa04c7a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go @@ -0,0 +1,95 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSClassicComputeVMProtectedItem{} + +type AzureIaaSClassicComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMProtectedItem{} + +func (s AzureIaaSClassicComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaascomputevmprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaascomputevmprotecteditem.go new file mode 100644 index 000000000000..2fbef6146f03 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaascomputevmprotecteditem.go @@ -0,0 +1,95 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSComputeVMProtectedItem{} + +type AzureIaaSComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSComputeVMProtectedItem{} + +func (s AzureIaaSComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasvmprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasvmprotecteditem.go new file mode 100644 index 000000000000..14088bfb3907 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasvmprotecteditem.go @@ -0,0 +1,95 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSVMProtectedItem{} + +type AzureIaaSVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSVMProtectedItem{} + +func (s AzureIaaSVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureIaaSVMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go new file mode 100644 index 000000000000..36c092fb4106 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go @@ -0,0 +1,67 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMProtectedItemExtendedInfo struct { + NewestRecoveryPointInArchive *string `json:"newestRecoveryPointInArchive,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OldestRecoveryPointInArchive *string `json:"oldestRecoveryPointInArchive,omitempty"` + OldestRecoveryPointInVault *string `json:"oldestRecoveryPointInVault,omitempty"` + PolicyInconsistent *bool `json:"policyInconsistent,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetNewestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.NewestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NewestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetNewestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NewestRecoveryPointInArchive = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInArchive = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointInVaultAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInVault == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInVault, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointInVaultAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInVault = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azuresqlprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azuresqlprotecteditem.go new file mode 100644 index 000000000000..553e36a1fc67 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azuresqlprotecteditem.go @@ -0,0 +1,86 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureSqlProtectedItem{} + +type AzureSqlProtectedItem struct { + ExtendedInfo *AzureSqlProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureSqlProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureSqlProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureSqlProtectedItem{} + +func (s AzureSqlProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Sql/servers/databases" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go new file mode 100644 index 000000000000..3b6ba503042a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go @@ -0,0 +1,28 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureSqlProtectedItemExtendedInfo struct { + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureSqlProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadprotecteditem.go new file mode 100644 index 000000000000..d0d45470590c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadprotecteditem.go @@ -0,0 +1,96 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadProtectedItem{} + +type AzureVMWorkloadProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadProtectedItem{} + +func (s AzureVMWorkloadProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go new file mode 100644 index 000000000000..e51960b91cf4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go @@ -0,0 +1,68 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureVMWorkloadProtectedItemExtendedInfo struct { + NewestRecoveryPointInArchive *string `json:"newestRecoveryPointInArchive,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OldestRecoveryPointInArchive *string `json:"oldestRecoveryPointInArchive,omitempty"` + OldestRecoveryPointInVault *string `json:"oldestRecoveryPointInVault,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryModel *string `json:"recoveryModel,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetNewestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.NewestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NewestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetNewestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NewestRecoveryPointInArchive = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInArchive = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointInVaultAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInVault == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInVault, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointInVaultAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInVault = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go new file mode 100644 index 000000000000..c985328f8b36 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go @@ -0,0 +1,96 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSAPAseDatabaseProtectedItem{} + +type AzureVMWorkloadSAPAseDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPAseDatabaseProtectedItem{} + +func (s AzureVMWorkloadSAPAseDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPAseDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSAPAseDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go new file mode 100644 index 000000000000..278abe93276f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go @@ -0,0 +1,96 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSAPHanaDatabaseProtectedItem{} + +type AzureVMWorkloadSAPHanaDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDatabaseProtectedItem{} + +func (s AzureVMWorkloadSAPHanaDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSAPHanaDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go new file mode 100644 index 000000000000..2ff78590c2d8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go @@ -0,0 +1,96 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSQLDatabaseProtectedItem{} + +type AzureVMWorkloadSQLDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSQLDatabaseProtectedItem{} + +func (s AzureVMWorkloadSQLDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSQLDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_diskexclusionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_diskexclusionproperties.go new file mode 100644 index 000000000000..17d722bc609c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_diskexclusionproperties.go @@ -0,0 +1,9 @@ +package protecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskExclusionProperties struct { + DiskLunList *[]int64 `json:"diskLunList,omitempty"` + IsInclusionList *bool `json:"isInclusionList,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_dpmprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_dpmprotecteditem.go new file mode 100644 index 000000000000..94681904fac0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_dpmprotecteditem.go @@ -0,0 +1,87 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = DPMProtectedItem{} + +type DPMProtectedItem struct { + BackupEngineName *string `json:"backupEngineName,omitempty"` + ExtendedInfo *DPMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *DPMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *DPMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = DPMProtectedItem{} + +func (s DPMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper DPMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DPMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DPMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "DPMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DPMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_dpmprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_dpmprotecteditemextendedinfo.go new file mode 100644 index 000000000000..fc6f9e8cd52f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_dpmprotecteditemextendedinfo.go @@ -0,0 +1,75 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DPMProtectedItemExtendedInfo struct { + DiskStorageUsedInBytes *string `json:"diskStorageUsedInBytes,omitempty"` + IsCollocated *bool `json:"isCollocated,omitempty"` + IsPresentOnCloud *bool `json:"isPresentOnCloud,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OnPremiseLatestRecoveryPoint *string `json:"onPremiseLatestRecoveryPoint,omitempty"` + OnPremiseOldestRecoveryPoint *string `json:"onPremiseOldestRecoveryPoint,omitempty"` + OnPremiseRecoveryPointCount *int64 `json:"onPremiseRecoveryPointCount,omitempty"` + ProtectableObjectLoadPath *map[string]string `json:"protectableObjectLoadPath,omitempty"` + Protected *bool `json:"protected,omitempty"` + ProtectionGroupName *string `json:"protectionGroupName,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` + TotalDiskStorageSizeInBytes *string `json:"totalDiskStorageSizeInBytes,omitempty"` +} + +func (o *DPMProtectedItemExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOnPremiseLatestRecoveryPointAsTime() (*time.Time, error) { + if o.OnPremiseLatestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OnPremiseLatestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOnPremiseLatestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OnPremiseLatestRecoveryPoint = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOnPremiseOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OnPremiseOldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OnPremiseOldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOnPremiseOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OnPremiseOldestRecoveryPoint = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_errordetail.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_errordetail.go new file mode 100644 index 000000000000..e3fa04c50a36 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_errordetail.go @@ -0,0 +1,10 @@ +package protecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_extendedproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_extendedproperties.go new file mode 100644 index 000000000000..fe926ccaa091 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_extendedproperties.go @@ -0,0 +1,9 @@ +package protecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedProperties struct { + DiskExclusionProperties *DiskExclusionProperties `json:"diskExclusionProperties,omitempty"` + LinuxVMApplicationName *string `json:"linuxVmApplicationName,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_genericprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_genericprotecteditem.go new file mode 100644 index 000000000000..75371cdd881c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_genericprotecteditem.go @@ -0,0 +1,89 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = GenericProtectedItem{} + +type GenericProtectedItem struct { + FabricName *string `json:"fabricName,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + ProtectedItemId *int64 `json:"protectedItemId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + SourceAssociations *map[string]string `json:"sourceAssociations,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *GenericProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *GenericProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = GenericProtectedItem{} + +func (s GenericProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper GenericProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "GenericProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_kpiresourcehealthdetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_kpiresourcehealthdetails.go new file mode 100644 index 000000000000..6cef5da36133 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_kpiresourcehealthdetails.go @@ -0,0 +1,9 @@ +package protecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KPIResourceHealthDetails struct { + ResourceHealthDetails *[]ResourceHealthDetails `json:"resourceHealthDetails,omitempty"` + ResourceHealthStatus *ResourceHealthStatus `json:"resourceHealthStatus,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_mabfilefolderprotecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_mabfilefolderprotecteditem.go new file mode 100644 index 000000000000..048df77148a4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_mabfilefolderprotecteditem.go @@ -0,0 +1,90 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = MabFileFolderProtectedItem{} + +type MabFileFolderProtectedItem struct { + ComputerName *string `json:"computerName,omitempty"` + DeferredDeleteSyncTimeInUTC *int64 `json:"deferredDeleteSyncTimeInUTC,omitempty"` + ExtendedInfo *MabFileFolderProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *MabFileFolderProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *MabFileFolderProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = MabFileFolderProtectedItem{} + +func (s MabFileFolderProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper MabFileFolderProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabFileFolderProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabFileFolderProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "MabFileFolderProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabFileFolderProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go new file mode 100644 index 000000000000..fbb9afca9714 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go @@ -0,0 +1,40 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabFileFolderProtectedItemExtendedInfo struct { + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *MabFileFolderProtectedItemExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItemExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} + +func (o *MabFileFolderProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_protecteditem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_protecteditem.go new file mode 100644 index 000000000000..3199f0ce423d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_protecteditem.go @@ -0,0 +1,136 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItem interface { +} + +func unmarshalProtectedItemImplementation(input []byte) (ProtectedItem, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectedItem into map[string]interface: %+v", err) + } + + value, ok := temp["protectedItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareProtectedItem") { + var out AzureFileshareProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileshareProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaaSVMProtectedItem") { + var out AzureIaaSVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Sql/servers/databases") { + var out AzureSqlProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadProtectedItem") { + var out AzureVMWorkloadProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPAseDatabase") { + var out AzureVMWorkloadSAPAseDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPHanaDatabase") { + var out AzureVMWorkloadSAPHanaDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSQLDatabase") { + var out AzureVMWorkloadSQLDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DPMProtectedItem") { + var out DPMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DPMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericProtectedItem") { + var out GenericProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MabFileFolderProtectedItem") { + var out MabFileFolderProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabFileFolderProtectedItem: %+v", err) + } + return out, nil + } + + type RawProtectedItemImpl struct { + Type string `json:"-"` + Values map[string]interface{} `json:"-"` + } + out := RawProtectedItemImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_protecteditemresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_protecteditemresource.go new file mode 100644 index 000000000000..0541c1a67bac --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_protecteditemresource.go @@ -0,0 +1,50 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItemResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectedItem `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectedItemResource{} + +func (s *ProtectedItemResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectedItemResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectedItemResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectedItemResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectedItemImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectedItemResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_resourcehealthdetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_resourcehealthdetails.go new file mode 100644 index 000000000000..867102078577 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/model_resourcehealthdetails.go @@ -0,0 +1,11 @@ +package protecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthDetails struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/version.go new file mode 100644 index 000000000000..5d6507d0683b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems/version.go @@ -0,0 +1,12 @@ +package protecteditems + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protecteditems/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/README.md new file mode 100644 index 000000000000..6150b97fb551 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/README.md @@ -0,0 +1,105 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers` Documentation + +The `protectioncontainers` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2021-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers" +``` + + +### Client Initialization + +```go +client := protectioncontainers.NewProtectionContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectionContainersClient.Get` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionContainersClient.Inquire` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +read, err := client.Inquire(ctx, id, protectioncontainers.DefaultInquireOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionContainersClient.Refresh` + +```go +ctx := context.TODO() +id := protectioncontainers.NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue") + +read, err := client.Refresh(ctx, id, protectioncontainers.DefaultRefreshOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionContainersClient.Register` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +payload := protectioncontainers.ProtectionContainerResource{ + // ... +} + + +read, err := client.Register(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionContainersClient.Unregister` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +read, err := client.Unregister(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/client.go new file mode 100644 index 000000000000..a3766493d9dd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/client.go @@ -0,0 +1,18 @@ +package protectioncontainers + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainersClient struct { + Client autorest.Client + baseUri string +} + +func NewProtectionContainersClientWithBaseURI(endpoint string) ProtectionContainersClient { + return ProtectionContainersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/constants.go new file mode 100644 index 000000000000..dea6f07fa4a5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/constants.go @@ -0,0 +1,324 @@ +package protectioncontainers + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AcquireStorageAccountLock string + +const ( + AcquireStorageAccountLockAcquire AcquireStorageAccountLock = "Acquire" + AcquireStorageAccountLockNotAcquire AcquireStorageAccountLock = "NotAcquire" +) + +func PossibleValuesForAcquireStorageAccountLock() []string { + return []string{ + string(AcquireStorageAccountLockAcquire), + string(AcquireStorageAccountLockNotAcquire), + } +} + +func parseAcquireStorageAccountLock(input string) (*AcquireStorageAccountLock, error) { + vals := map[string]AcquireStorageAccountLock{ + "acquire": AcquireStorageAccountLockAcquire, + "notacquire": AcquireStorageAccountLockNotAcquire, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AcquireStorageAccountLock(input) + return &out, nil +} + +type BackupItemType string + +const ( + BackupItemTypeAzureFileShare BackupItemType = "AzureFileShare" + BackupItemTypeAzureSqlDb BackupItemType = "AzureSqlDb" + BackupItemTypeClient BackupItemType = "Client" + BackupItemTypeExchange BackupItemType = "Exchange" + BackupItemTypeFileFolder BackupItemType = "FileFolder" + BackupItemTypeGenericDataSource BackupItemType = "GenericDataSource" + BackupItemTypeInvalid BackupItemType = "Invalid" + BackupItemTypeSAPAseDatabase BackupItemType = "SAPAseDatabase" + BackupItemTypeSAPHanaDatabase BackupItemType = "SAPHanaDatabase" + BackupItemTypeSQLDB BackupItemType = "SQLDB" + BackupItemTypeSQLDataBase BackupItemType = "SQLDataBase" + BackupItemTypeSharepoint BackupItemType = "Sharepoint" + BackupItemTypeSystemState BackupItemType = "SystemState" + BackupItemTypeVM BackupItemType = "VM" + BackupItemTypeVMwareVM BackupItemType = "VMwareVM" +) + +func PossibleValuesForBackupItemType() []string { + return []string{ + string(BackupItemTypeAzureFileShare), + string(BackupItemTypeAzureSqlDb), + string(BackupItemTypeClient), + string(BackupItemTypeExchange), + string(BackupItemTypeFileFolder), + string(BackupItemTypeGenericDataSource), + string(BackupItemTypeInvalid), + string(BackupItemTypeSAPAseDatabase), + string(BackupItemTypeSAPHanaDatabase), + string(BackupItemTypeSQLDB), + string(BackupItemTypeSQLDataBase), + string(BackupItemTypeSharepoint), + string(BackupItemTypeSystemState), + string(BackupItemTypeVM), + string(BackupItemTypeVMwareVM), + } +} + +func parseBackupItemType(input string) (*BackupItemType, error) { + vals := map[string]BackupItemType{ + "azurefileshare": BackupItemTypeAzureFileShare, + "azuresqldb": BackupItemTypeAzureSqlDb, + "client": BackupItemTypeClient, + "exchange": BackupItemTypeExchange, + "filefolder": BackupItemTypeFileFolder, + "genericdatasource": BackupItemTypeGenericDataSource, + "invalid": BackupItemTypeInvalid, + "sapasedatabase": BackupItemTypeSAPAseDatabase, + "saphanadatabase": BackupItemTypeSAPHanaDatabase, + "sqldb": BackupItemTypeSQLDB, + "sqldatabase": BackupItemTypeSQLDataBase, + "sharepoint": BackupItemTypeSharepoint, + "systemstate": BackupItemTypeSystemState, + "vm": BackupItemTypeVM, + "vmwarevm": BackupItemTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupItemType(input) + return &out, nil +} + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type ContainerType string + +const ( + ContainerTypeAzureBackupServerContainer ContainerType = "AzureBackupServerContainer" + ContainerTypeAzureSqlContainer ContainerType = "AzureSqlContainer" + ContainerTypeAzureWorkloadContainer ContainerType = "AzureWorkloadContainer" + ContainerTypeCluster ContainerType = "Cluster" + ContainerTypeDPMContainer ContainerType = "DPMContainer" + ContainerTypeGenericContainer ContainerType = "GenericContainer" + ContainerTypeIaasVMContainer ContainerType = "IaasVMContainer" + ContainerTypeIaasVMServiceContainer ContainerType = "IaasVMServiceContainer" + ContainerTypeInvalid ContainerType = "Invalid" + ContainerTypeMABContainer ContainerType = "MABContainer" + ContainerTypeMicrosoftPointClassicComputeVirtualMachines ContainerType = "Microsoft.ClassicCompute/virtualMachines" + ContainerTypeMicrosoftPointComputeVirtualMachines ContainerType = "Microsoft.Compute/virtualMachines" + ContainerTypeSQLAGWorkLoadContainer ContainerType = "SQLAGWorkLoadContainer" + ContainerTypeStorageContainer ContainerType = "StorageContainer" + ContainerTypeUnknown ContainerType = "Unknown" + ContainerTypeVCenter ContainerType = "VCenter" + ContainerTypeVMAppContainer ContainerType = "VMAppContainer" + ContainerTypeWindows ContainerType = "Windows" +) + +func PossibleValuesForContainerType() []string { + return []string{ + string(ContainerTypeAzureBackupServerContainer), + string(ContainerTypeAzureSqlContainer), + string(ContainerTypeAzureWorkloadContainer), + string(ContainerTypeCluster), + string(ContainerTypeDPMContainer), + string(ContainerTypeGenericContainer), + string(ContainerTypeIaasVMContainer), + string(ContainerTypeIaasVMServiceContainer), + string(ContainerTypeInvalid), + string(ContainerTypeMABContainer), + string(ContainerTypeMicrosoftPointClassicComputeVirtualMachines), + string(ContainerTypeMicrosoftPointComputeVirtualMachines), + string(ContainerTypeSQLAGWorkLoadContainer), + string(ContainerTypeStorageContainer), + string(ContainerTypeUnknown), + string(ContainerTypeVCenter), + string(ContainerTypeVMAppContainer), + string(ContainerTypeWindows), + } +} + +func parseContainerType(input string) (*ContainerType, error) { + vals := map[string]ContainerType{ + "azurebackupservercontainer": ContainerTypeAzureBackupServerContainer, + "azuresqlcontainer": ContainerTypeAzureSqlContainer, + "azureworkloadcontainer": ContainerTypeAzureWorkloadContainer, + "cluster": ContainerTypeCluster, + "dpmcontainer": ContainerTypeDPMContainer, + "genericcontainer": ContainerTypeGenericContainer, + "iaasvmcontainer": ContainerTypeIaasVMContainer, + "iaasvmservicecontainer": ContainerTypeIaasVMServiceContainer, + "invalid": ContainerTypeInvalid, + "mabcontainer": ContainerTypeMABContainer, + "microsoft.classiccompute/virtualmachines": ContainerTypeMicrosoftPointClassicComputeVirtualMachines, + "microsoft.compute/virtualmachines": ContainerTypeMicrosoftPointComputeVirtualMachines, + "sqlagworkloadcontainer": ContainerTypeSQLAGWorkLoadContainer, + "storagecontainer": ContainerTypeStorageContainer, + "unknown": ContainerTypeUnknown, + "vcenter": ContainerTypeVCenter, + "vmappcontainer": ContainerTypeVMAppContainer, + "windows": ContainerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContainerType(input) + return &out, nil +} + +type OperationType string + +const ( + OperationTypeInvalid OperationType = "Invalid" + OperationTypeRegister OperationType = "Register" + OperationTypeReregister OperationType = "Reregister" +) + +func PossibleValuesForOperationType() []string { + return []string{ + string(OperationTypeInvalid), + string(OperationTypeRegister), + string(OperationTypeReregister), + } +} + +func parseOperationType(input string) (*OperationType, error) { + vals := map[string]OperationType{ + "invalid": OperationTypeInvalid, + "register": OperationTypeRegister, + "reregister": OperationTypeReregister, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationType(input) + return &out, nil +} + +type WorkloadType string + +const ( + WorkloadTypeAzureFileShare WorkloadType = "AzureFileShare" + WorkloadTypeAzureSqlDb WorkloadType = "AzureSqlDb" + WorkloadTypeClient WorkloadType = "Client" + WorkloadTypeExchange WorkloadType = "Exchange" + WorkloadTypeFileFolder WorkloadType = "FileFolder" + WorkloadTypeGenericDataSource WorkloadType = "GenericDataSource" + WorkloadTypeInvalid WorkloadType = "Invalid" + WorkloadTypeSAPAseDatabase WorkloadType = "SAPAseDatabase" + WorkloadTypeSAPHanaDatabase WorkloadType = "SAPHanaDatabase" + WorkloadTypeSQLDB WorkloadType = "SQLDB" + WorkloadTypeSQLDataBase WorkloadType = "SQLDataBase" + WorkloadTypeSharepoint WorkloadType = "Sharepoint" + WorkloadTypeSystemState WorkloadType = "SystemState" + WorkloadTypeVM WorkloadType = "VM" + WorkloadTypeVMwareVM WorkloadType = "VMwareVM" +) + +func PossibleValuesForWorkloadType() []string { + return []string{ + string(WorkloadTypeAzureFileShare), + string(WorkloadTypeAzureSqlDb), + string(WorkloadTypeClient), + string(WorkloadTypeExchange), + string(WorkloadTypeFileFolder), + string(WorkloadTypeGenericDataSource), + string(WorkloadTypeInvalid), + string(WorkloadTypeSAPAseDatabase), + string(WorkloadTypeSAPHanaDatabase), + string(WorkloadTypeSQLDB), + string(WorkloadTypeSQLDataBase), + string(WorkloadTypeSharepoint), + string(WorkloadTypeSystemState), + string(WorkloadTypeVM), + string(WorkloadTypeVMwareVM), + } +} + +func parseWorkloadType(input string) (*WorkloadType, error) { + vals := map[string]WorkloadType{ + "azurefileshare": WorkloadTypeAzureFileShare, + "azuresqldb": WorkloadTypeAzureSqlDb, + "client": WorkloadTypeClient, + "exchange": WorkloadTypeExchange, + "filefolder": WorkloadTypeFileFolder, + "genericdatasource": WorkloadTypeGenericDataSource, + "invalid": WorkloadTypeInvalid, + "sapasedatabase": WorkloadTypeSAPAseDatabase, + "saphanadatabase": WorkloadTypeSAPHanaDatabase, + "sqldb": WorkloadTypeSQLDB, + "sqldatabase": WorkloadTypeSQLDataBase, + "sharepoint": WorkloadTypeSharepoint, + "systemstate": WorkloadTypeSystemState, + "vm": WorkloadTypeVM, + "vmwarevm": WorkloadTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/id_backupfabric.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/id_backupfabric.go new file mode 100644 index 000000000000..4ff2c3ffd694 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/id_backupfabric.go @@ -0,0 +1,140 @@ +package protectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = BackupFabricId{} + +// BackupFabricId is a struct representing the Resource ID for a Backup Fabric +type BackupFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string +} + +// NewBackupFabricID returns a new BackupFabricId struct +func NewBackupFabricID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string) BackupFabricId { + return BackupFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + } +} + +// ParseBackupFabricID parses 'input' into a BackupFabricId +func ParseBackupFabricID(input string) (*BackupFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(BackupFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := BackupFabricId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + if id.BackupFabricName, ok = parsed.Parsed["backupFabricName"]; !ok { + return nil, fmt.Errorf("the segment 'backupFabricName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseBackupFabricIDInsensitively parses 'input' case-insensitively into a BackupFabricId +// note: this method should only be used for API response data and not user input +func ParseBackupFabricIDInsensitively(input string) (*BackupFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(BackupFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := BackupFabricId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + if id.BackupFabricName, ok = parsed.Parsed["backupFabricName"]; !ok { + return nil, fmt.Errorf("the segment 'backupFabricName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateBackupFabricID checks that 'input' can be parsed as a Backup Fabric ID +func ValidateBackupFabricID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Fabric ID +func (id BackupFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Fabric ID +func (id BackupFabricId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + } +} + +// String returns a human-readable description of this Backup Fabric ID +func (id BackupFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + } + return fmt.Sprintf("Backup Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/id_protectioncontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/id_protectioncontainer.go new file mode 100644 index 000000000000..aed7a37ee361 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/id_protectioncontainer.go @@ -0,0 +1,153 @@ +package protectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = ProtectionContainerId{} + +// ProtectionContainerId is a struct representing the Resource ID for a Protection Container +type ProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string +} + +// NewProtectionContainerID returns a new ProtectionContainerId struct +func NewProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string) ProtectionContainerId { + return ProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + } +} + +// ParseProtectionContainerID parses 'input' into a ProtectionContainerId +func ParseProtectionContainerID(input string) (*ProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(ProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProtectionContainerId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + if id.BackupFabricName, ok = parsed.Parsed["backupFabricName"]; !ok { + return nil, fmt.Errorf("the segment 'backupFabricName' was not found in the resource id %q", input) + } + + if id.ProtectionContainerName, ok = parsed.Parsed["protectionContainerName"]; !ok { + return nil, fmt.Errorf("the segment 'protectionContainerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseProtectionContainerIDInsensitively parses 'input' case-insensitively into a ProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseProtectionContainerIDInsensitively(input string) (*ProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(ProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProtectionContainerId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + if id.BackupFabricName, ok = parsed.Parsed["backupFabricName"]; !ok { + return nil, fmt.Errorf("the segment 'backupFabricName' was not found in the resource id %q", input) + } + + if id.ProtectionContainerName, ok = parsed.Parsed["protectionContainerName"]; !ok { + return nil, fmt.Errorf("the segment 'protectionContainerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateProtectionContainerID checks that 'input' can be parsed as a Protection Container ID +func ValidateProtectionContainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Protection Container ID +func (id ProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Protection Container ID +func (id ProtectionContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + } +} + +// String returns a human-readable description of this Protection Container ID +func (id ProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + } + return fmt.Sprintf("Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_get_autorest.go new file mode 100644 index 000000000000..07d4c7101439 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_get_autorest.go @@ -0,0 +1,68 @@ +package protectioncontainers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *ProtectionContainerResource +} + +// Get ... +func (c ProtectionContainersClient) Get(ctx context.Context, id ProtectionContainerId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ProtectionContainersClient) preparerForGet(ctx context.Context, id ProtectionContainerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ProtectionContainersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_inquire_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_inquire_autorest.go new file mode 100644 index 000000000000..fb85971bffd1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_inquire_autorest.go @@ -0,0 +1,96 @@ +package protectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InquireOperationResponse struct { + HttpResponse *http.Response +} + +type InquireOperationOptions struct { + Filter *string +} + +func DefaultInquireOperationOptions() InquireOperationOptions { + return InquireOperationOptions{} +} + +func (o InquireOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o InquireOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// Inquire ... +func (c ProtectionContainersClient) Inquire(ctx context.Context, id ProtectionContainerId, options InquireOperationOptions) (result InquireOperationResponse, err error) { + req, err := c.preparerForInquire(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Inquire", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Inquire", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForInquire(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Inquire", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForInquire prepares the Inquire request. +func (c ProtectionContainersClient) preparerForInquire(ctx context.Context, id ProtectionContainerId, options InquireOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/inquire", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForInquire handles the response to the Inquire request. The method always +// closes the http.Response Body. +func (c ProtectionContainersClient) responderForInquire(resp *http.Response) (result InquireOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_refresh_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_refresh_autorest.go new file mode 100644 index 000000000000..2b4984af995a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_refresh_autorest.go @@ -0,0 +1,96 @@ +package protectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RefreshOperationResponse struct { + HttpResponse *http.Response +} + +type RefreshOperationOptions struct { + Filter *string +} + +func DefaultRefreshOperationOptions() RefreshOperationOptions { + return RefreshOperationOptions{} +} + +func (o RefreshOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o RefreshOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// Refresh ... +func (c ProtectionContainersClient) Refresh(ctx context.Context, id BackupFabricId, options RefreshOperationOptions) (result RefreshOperationResponse, err error) { + req, err := c.preparerForRefresh(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Refresh", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Refresh", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForRefresh(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Refresh", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForRefresh prepares the Refresh request. +func (c ProtectionContainersClient) preparerForRefresh(ctx context.Context, id BackupFabricId, options RefreshOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/refreshContainers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForRefresh handles the response to the Refresh request. The method always +// closes the http.Response Body. +func (c ProtectionContainersClient) responderForRefresh(resp *http.Response) (result RefreshOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_register_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_register_autorest.go new file mode 100644 index 000000000000..30b79c94a5ec --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_register_autorest.go @@ -0,0 +1,69 @@ +package protectioncontainers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegisterOperationResponse struct { + HttpResponse *http.Response + Model *ProtectionContainerResource +} + +// Register ... +func (c ProtectionContainersClient) Register(ctx context.Context, id ProtectionContainerId, input ProtectionContainerResource) (result RegisterOperationResponse, err error) { + req, err := c.preparerForRegister(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Register", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Register", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForRegister(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Register", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForRegister prepares the Register request. +func (c ProtectionContainersClient) preparerForRegister(ctx context.Context, id ProtectionContainerId, input ProtectionContainerResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForRegister handles the response to the Register request. The method always +// closes the http.Response Body. +func (c ProtectionContainersClient) responderForRegister(resp *http.Response) (result RegisterOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_unregister_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_unregister_autorest.go new file mode 100644 index 000000000000..cf4fbebe1287 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/method_unregister_autorest.go @@ -0,0 +1,66 @@ +package protectioncontainers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnregisterOperationResponse struct { + HttpResponse *http.Response +} + +// Unregister ... +func (c ProtectionContainersClient) Unregister(ctx context.Context, id ProtectionContainerId) (result UnregisterOperationResponse, err error) { + req, err := c.preparerForUnregister(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Unregister", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Unregister", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUnregister(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Unregister", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUnregister prepares the Unregister request. +func (c ProtectionContainersClient) preparerForUnregister(ctx context.Context, id ProtectionContainerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUnregister handles the response to the Unregister request. The method always +// closes the http.Response Body. +func (c ProtectionContainersClient) responderForUnregister(resp *http.Response) (result UnregisterOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurebackupservercontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurebackupservercontainer.go new file mode 100644 index 000000000000..1c21d8906f9f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurebackupservercontainer.go @@ -0,0 +1,53 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureBackupServerContainer{} + +type AzureBackupServerContainer struct { + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + DpmAgentVersion *string `json:"dpmAgentVersion,omitempty"` + DpmServers *[]string `json:"dpmServers,omitempty"` + ExtendedInfo *DPMContainerExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + UpgradeAvailable *bool `json:"upgradeAvailable,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureBackupServerContainer{} + +func (s AzureBackupServerContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupServerContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupServerContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupServerContainer: %+v", err) + } + decoded["containerType"] = "AzureBackupServerContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupServerContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go new file mode 100644 index 000000000000..b8a8c17717e1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go @@ -0,0 +1,48 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureIaaSClassicComputeVMContainer{} + +type AzureIaaSClassicComputeVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMContainer{} + +func (s AzureIaaSClassicComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureiaascomputevmcontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureiaascomputevmcontainer.go new file mode 100644 index 000000000000..c66beff2ce09 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureiaascomputevmcontainer.go @@ -0,0 +1,48 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureIaaSComputeVMContainer{} + +type AzureIaaSComputeVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSComputeVMContainer{} + +func (s AzureIaaSComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go new file mode 100644 index 000000000000..7e0a1ed3e946 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureSQLAGWorkloadContainerProtectionContainer{} + +type AzureSQLAGWorkloadContainerProtectionContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSQLAGWorkloadContainerProtectionContainer{} + +func (s AzureSQLAGWorkloadContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSQLAGWorkloadContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "SQLAGWorkLoadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azuresqlcontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azuresqlcontainer.go new file mode 100644 index 000000000000..cd29b673055f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azuresqlcontainer.go @@ -0,0 +1,45 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureSqlContainer{} + +type AzureSqlContainer struct { + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSqlContainer{} + +func (s AzureSqlContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlContainer: %+v", err) + } + decoded["containerType"] = "AzureSqlContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurestoragecontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurestoragecontainer.go new file mode 100644 index 000000000000..fc4de5fe9407 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurestoragecontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureStorageContainer{} + +type AzureStorageContainer struct { + AcquireStorageAccountLock *AcquireStorageAccountLock `json:"acquireStorageAccountLock,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountVersion *string `json:"storageAccountVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureStorageContainer{} + +func (s AzureStorageContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageContainer: %+v", err) + } + decoded["containerType"] = "StorageContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go new file mode 100644 index 000000000000..97d2dbf49f8a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureVMAppContainerProtectionContainer{} + +type AzureVMAppContainerProtectionContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureVMAppContainerProtectionContainer{} + +func (s AzureVMAppContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureVMAppContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "VMAppContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureworkloadcontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureworkloadcontainer.go new file mode 100644 index 000000000000..792903391564 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureworkloadcontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureWorkloadContainer{} + +type AzureWorkloadContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadContainer{} + +func (s AzureWorkloadContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadContainer: %+v", err) + } + decoded["containerType"] = "AzureWorkloadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go new file mode 100644 index 000000000000..3306d7014ef3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadContainerExtendedInfo struct { + HostServerName *string `json:"hostServerName,omitempty"` + InquiryInfo *InquiryInfo `json:"inquiryInfo,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_containeridentityinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_containeridentityinfo.go new file mode 100644 index 000000000000..2a757b599d66 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_containeridentityinfo.go @@ -0,0 +1,11 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerIdentityInfo struct { + AadTenantId *string `json:"aadTenantId,omitempty"` + Audience *string `json:"audience,omitempty"` + ServicePrincipalClientId *string `json:"servicePrincipalClientId,omitempty"` + UniqueName *string `json:"uniqueName,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_distributednodesinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_distributednodesinfo.go new file mode 100644 index 000000000000..96186902d6a8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_distributednodesinfo.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DistributedNodesInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + NodeName *string `json:"nodeName,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_dpmcontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_dpmcontainer.go new file mode 100644 index 000000000000..d35b9a9844da --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_dpmcontainer.go @@ -0,0 +1,53 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = DpmContainer{} + +type DpmContainer struct { + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + DpmAgentVersion *string `json:"dpmAgentVersion,omitempty"` + DpmServers *[]string `json:"dpmServers,omitempty"` + ExtendedInfo *DPMContainerExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + UpgradeAvailable *bool `json:"upgradeAvailable,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = DpmContainer{} + +func (s DpmContainer) MarshalJSON() ([]byte, error) { + type wrapper DpmContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmContainer: %+v", err) + } + decoded["containerType"] = "DPMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_dpmcontainerextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_dpmcontainerextendedinfo.go new file mode 100644 index 000000000000..608a1ba48f9f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_dpmcontainerextendedinfo.go @@ -0,0 +1,26 @@ +package protectioncontainers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DPMContainerExtendedInfo struct { + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` +} + +func (o *DPMContainerExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMContainerExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_errordetail.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_errordetail.go new file mode 100644 index 000000000000..6eac856c4046 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_errordetail.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_genericcontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_genericcontainer.go new file mode 100644 index 000000000000..45b661347c13 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_genericcontainer.go @@ -0,0 +1,47 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = GenericContainer{} + +type GenericContainer struct { + ExtendedInformation *GenericContainerExtendedInfo `json:"extendedInformation,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = GenericContainer{} + +func (s GenericContainer) MarshalJSON() ([]byte, error) { + type wrapper GenericContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericContainer: %+v", err) + } + decoded["containerType"] = "GenericContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_genericcontainerextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_genericcontainerextendedinfo.go new file mode 100644 index 000000000000..6d1b2f49b6bc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_genericcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenericContainerExtendedInfo struct { + ContainerIdentityInfo *ContainerIdentityInfo `json:"containerIdentityInfo,omitempty"` + RawCertData *string `json:"rawCertData,omitempty"` + ServiceEndpoints *map[string]string `json:"serviceEndpoints,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_iaasvmcontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_iaasvmcontainer.go new file mode 100644 index 000000000000..e0a2bd351495 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_iaasvmcontainer.go @@ -0,0 +1,48 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = IaaSVMContainer{} + +type IaaSVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = IaaSVMContainer{} + +func (s IaaSVMContainer) MarshalJSON() ([]byte, error) { + type wrapper IaaSVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaaSVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaaSVMContainer: %+v", err) + } + decoded["containerType"] = "IaasVMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaaSVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_inquiryinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_inquiryinfo.go new file mode 100644 index 000000000000..53bfc1db9115 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_inquiryinfo.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InquiryInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + InquiryDetails *[]WorkloadInquiryDetails `json:"inquiryDetails,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_inquiryvalidation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_inquiryvalidation.go new file mode 100644 index 000000000000..ab89a15d5ec5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_inquiryvalidation.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InquiryValidation struct { + AdditionalDetail *string `json:"additionalDetail,omitempty"` + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainer.go new file mode 100644 index 000000000000..b2d5eb97307b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainer.go @@ -0,0 +1,52 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = MabContainer{} + +type MabContainer struct { + AgentVersion *string `json:"agentVersion,omitempty"` + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerHealthState *string `json:"containerHealthState,omitempty"` + ContainerId *int64 `json:"containerId,omitempty"` + ExtendedInfo *MabContainerExtendedInfo `json:"extendedInfo,omitempty"` + MabContainerHealthDetails *[]MABContainerHealthDetails `json:"mabContainerHealthDetails,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = MabContainer{} + +func (s MabContainer) MarshalJSON() ([]byte, error) { + type wrapper MabContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabContainer: %+v", err) + } + decoded["containerType"] = "Windows" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabContainer: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainerextendedinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainerextendedinfo.go new file mode 100644 index 000000000000..82aeca609c68 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainerextendedinfo.go @@ -0,0 +1,30 @@ +package protectioncontainers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabContainerExtendedInfo struct { + BackupItemType *BackupItemType `json:"backupItemType,omitempty"` + BackupItems *[]string `json:"backupItems,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + PolicyName *string `json:"policyName,omitempty"` +} + +func (o *MabContainerExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabContainerExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainerhealthdetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainerhealthdetails.go new file mode 100644 index 000000000000..1bc3a8072850 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_mabcontainerhealthdetails.go @@ -0,0 +1,11 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MABContainerHealthDetails struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_protectioncontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_protectioncontainer.go new file mode 100644 index 000000000000..b7edc7f494da --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_protectioncontainer.go @@ -0,0 +1,136 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainer interface { +} + +func unmarshalProtectionContainerImplementation(input []byte) (ProtectionContainer, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionContainer into map[string]interface: %+v", err) + } + + value, ok := temp["containerType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupServerContainer") { + var out AzureBackupServerContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupServerContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLAGWorkLoadContainer") { + var out AzureSQLAGWorkloadContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSqlContainer") { + var out AzureSqlContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "StorageContainer") { + var out AzureStorageContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMAppContainer") { + var out AzureVMAppContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMAppContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadContainer") { + var out AzureWorkloadContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DPMContainer") { + var out DpmContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericContainer") { + var out GenericContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMContainer") { + var out IaaSVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaaSVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Windows") { + var out MabContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabContainer: %+v", err) + } + return out, nil + } + + type RawProtectionContainerImpl struct { + Type string `json:"-"` + Values map[string]interface{} `json:"-"` + } + out := RawProtectionContainerImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_protectioncontainerresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_protectioncontainerresource.go new file mode 100644 index 000000000000..4de75e086024 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_protectioncontainerresource.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionContainer `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionContainerResource{} + +func (s *ProtectionContainerResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionContainerResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionContainerResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionContainerResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionContainerImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionContainerResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_workloadinquirydetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_workloadinquirydetails.go new file mode 100644 index 000000000000..1e9d14137439 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/model_workloadinquirydetails.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadInquiryDetails struct { + InquiryValidation *InquiryValidation `json:"inquiryValidation,omitempty"` + ItemCount *int64 `json:"itemCount,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/version.go new file mode 100644 index 000000000000..f22c3d8367d1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers/version.go @@ -0,0 +1,12 @@ +package protectioncontainers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protectioncontainers/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/README.md new file mode 100644 index 000000000000..ef9894ad3454 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/README.md @@ -0,0 +1,69 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies` Documentation + +The `protectionpolicies` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2021-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies" +``` + + +### Client Initialization + +```go +client := protectionpolicies.NewProtectionPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectionPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := protectionpolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue") + +payload := protectionpolicies.ProtectionPolicyResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := protectionpolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProtectionPoliciesClient.Get` + +```go +ctx := context.TODO() +id := protectionpolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/client.go new file mode 100644 index 000000000000..af96d5ee4b70 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/client.go @@ -0,0 +1,18 @@ +package protectionpolicies + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionPoliciesClient struct { + Client autorest.Client + baseUri string +} + +func NewProtectionPoliciesClientWithBaseURI(endpoint string) ProtectionPoliciesClient { + return ProtectionPoliciesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/constants.go new file mode 100644 index 000000000000..115c4b6b0703 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/constants.go @@ -0,0 +1,424 @@ +package protectionpolicies + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DayOfWeek string + +const ( + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +func PossibleValuesForDayOfWeek() []string { + return []string{ + string(DayOfWeekFriday), + string(DayOfWeekMonday), + string(DayOfWeekSaturday), + string(DayOfWeekSunday), + string(DayOfWeekThursday), + string(DayOfWeekTuesday), + string(DayOfWeekWednesday), + } +} + +func parseDayOfWeek(input string) (*DayOfWeek, error) { + vals := map[string]DayOfWeek{ + "friday": DayOfWeekFriday, + "monday": DayOfWeekMonday, + "saturday": DayOfWeekSaturday, + "sunday": DayOfWeekSunday, + "thursday": DayOfWeekThursday, + "tuesday": DayOfWeekTuesday, + "wednesday": DayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeek(input) + return &out, nil +} + +type IAASVMPolicyType string + +const ( + IAASVMPolicyTypeInvalid IAASVMPolicyType = "Invalid" + IAASVMPolicyTypeVOne IAASVMPolicyType = "V1" + IAASVMPolicyTypeVTwo IAASVMPolicyType = "V2" +) + +func PossibleValuesForIAASVMPolicyType() []string { + return []string{ + string(IAASVMPolicyTypeInvalid), + string(IAASVMPolicyTypeVOne), + string(IAASVMPolicyTypeVTwo), + } +} + +func parseIAASVMPolicyType(input string) (*IAASVMPolicyType, error) { + vals := map[string]IAASVMPolicyType{ + "invalid": IAASVMPolicyTypeInvalid, + "v1": IAASVMPolicyTypeVOne, + "v2": IAASVMPolicyTypeVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IAASVMPolicyType(input) + return &out, nil +} + +type MonthOfYear string + +const ( + MonthOfYearApril MonthOfYear = "April" + MonthOfYearAugust MonthOfYear = "August" + MonthOfYearDecember MonthOfYear = "December" + MonthOfYearFebruary MonthOfYear = "February" + MonthOfYearInvalid MonthOfYear = "Invalid" + MonthOfYearJanuary MonthOfYear = "January" + MonthOfYearJuly MonthOfYear = "July" + MonthOfYearJune MonthOfYear = "June" + MonthOfYearMarch MonthOfYear = "March" + MonthOfYearMay MonthOfYear = "May" + MonthOfYearNovember MonthOfYear = "November" + MonthOfYearOctober MonthOfYear = "October" + MonthOfYearSeptember MonthOfYear = "September" +) + +func PossibleValuesForMonthOfYear() []string { + return []string{ + string(MonthOfYearApril), + string(MonthOfYearAugust), + string(MonthOfYearDecember), + string(MonthOfYearFebruary), + string(MonthOfYearInvalid), + string(MonthOfYearJanuary), + string(MonthOfYearJuly), + string(MonthOfYearJune), + string(MonthOfYearMarch), + string(MonthOfYearMay), + string(MonthOfYearNovember), + string(MonthOfYearOctober), + string(MonthOfYearSeptember), + } +} + +func parseMonthOfYear(input string) (*MonthOfYear, error) { + vals := map[string]MonthOfYear{ + "april": MonthOfYearApril, + "august": MonthOfYearAugust, + "december": MonthOfYearDecember, + "february": MonthOfYearFebruary, + "invalid": MonthOfYearInvalid, + "january": MonthOfYearJanuary, + "july": MonthOfYearJuly, + "june": MonthOfYearJune, + "march": MonthOfYearMarch, + "may": MonthOfYearMay, + "november": MonthOfYearNovember, + "october": MonthOfYearOctober, + "september": MonthOfYearSeptember, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonthOfYear(input) + return &out, nil +} + +type PolicyType string + +const ( + PolicyTypeCopyOnlyFull PolicyType = "CopyOnlyFull" + PolicyTypeDifferential PolicyType = "Differential" + PolicyTypeFull PolicyType = "Full" + PolicyTypeIncremental PolicyType = "Incremental" + PolicyTypeInvalid PolicyType = "Invalid" + PolicyTypeLog PolicyType = "Log" +) + +func PossibleValuesForPolicyType() []string { + return []string{ + string(PolicyTypeCopyOnlyFull), + string(PolicyTypeDifferential), + string(PolicyTypeFull), + string(PolicyTypeIncremental), + string(PolicyTypeInvalid), + string(PolicyTypeLog), + } +} + +func parsePolicyType(input string) (*PolicyType, error) { + vals := map[string]PolicyType{ + "copyonlyfull": PolicyTypeCopyOnlyFull, + "differential": PolicyTypeDifferential, + "full": PolicyTypeFull, + "incremental": PolicyTypeIncremental, + "invalid": PolicyTypeInvalid, + "log": PolicyTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyType(input) + return &out, nil +} + +type RetentionDurationType string + +const ( + RetentionDurationTypeDays RetentionDurationType = "Days" + RetentionDurationTypeInvalid RetentionDurationType = "Invalid" + RetentionDurationTypeMonths RetentionDurationType = "Months" + RetentionDurationTypeWeeks RetentionDurationType = "Weeks" + RetentionDurationTypeYears RetentionDurationType = "Years" +) + +func PossibleValuesForRetentionDurationType() []string { + return []string{ + string(RetentionDurationTypeDays), + string(RetentionDurationTypeInvalid), + string(RetentionDurationTypeMonths), + string(RetentionDurationTypeWeeks), + string(RetentionDurationTypeYears), + } +} + +func parseRetentionDurationType(input string) (*RetentionDurationType, error) { + vals := map[string]RetentionDurationType{ + "days": RetentionDurationTypeDays, + "invalid": RetentionDurationTypeInvalid, + "months": RetentionDurationTypeMonths, + "weeks": RetentionDurationTypeWeeks, + "years": RetentionDurationTypeYears, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RetentionDurationType(input) + return &out, nil +} + +type RetentionScheduleFormat string + +const ( + RetentionScheduleFormatDaily RetentionScheduleFormat = "Daily" + RetentionScheduleFormatInvalid RetentionScheduleFormat = "Invalid" + RetentionScheduleFormatWeekly RetentionScheduleFormat = "Weekly" +) + +func PossibleValuesForRetentionScheduleFormat() []string { + return []string{ + string(RetentionScheduleFormatDaily), + string(RetentionScheduleFormatInvalid), + string(RetentionScheduleFormatWeekly), + } +} + +func parseRetentionScheduleFormat(input string) (*RetentionScheduleFormat, error) { + vals := map[string]RetentionScheduleFormat{ + "daily": RetentionScheduleFormatDaily, + "invalid": RetentionScheduleFormatInvalid, + "weekly": RetentionScheduleFormatWeekly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RetentionScheduleFormat(input) + return &out, nil +} + +type ScheduleRunType string + +const ( + ScheduleRunTypeDaily ScheduleRunType = "Daily" + ScheduleRunTypeHourly ScheduleRunType = "Hourly" + ScheduleRunTypeInvalid ScheduleRunType = "Invalid" + ScheduleRunTypeWeekly ScheduleRunType = "Weekly" +) + +func PossibleValuesForScheduleRunType() []string { + return []string{ + string(ScheduleRunTypeDaily), + string(ScheduleRunTypeHourly), + string(ScheduleRunTypeInvalid), + string(ScheduleRunTypeWeekly), + } +} + +func parseScheduleRunType(input string) (*ScheduleRunType, error) { + vals := map[string]ScheduleRunType{ + "daily": ScheduleRunTypeDaily, + "hourly": ScheduleRunTypeHourly, + "invalid": ScheduleRunTypeInvalid, + "weekly": ScheduleRunTypeWeekly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduleRunType(input) + return &out, nil +} + +type TieringMode string + +const ( + TieringModeDoNotTier TieringMode = "DoNotTier" + TieringModeInvalid TieringMode = "Invalid" + TieringModeTierAfter TieringMode = "TierAfter" + TieringModeTierRecommended TieringMode = "TierRecommended" +) + +func PossibleValuesForTieringMode() []string { + return []string{ + string(TieringModeDoNotTier), + string(TieringModeInvalid), + string(TieringModeTierAfter), + string(TieringModeTierRecommended), + } +} + +func parseTieringMode(input string) (*TieringMode, error) { + vals := map[string]TieringMode{ + "donottier": TieringModeDoNotTier, + "invalid": TieringModeInvalid, + "tierafter": TieringModeTierAfter, + "tierrecommended": TieringModeTierRecommended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TieringMode(input) + return &out, nil +} + +type WeekOfMonth string + +const ( + WeekOfMonthFirst WeekOfMonth = "First" + WeekOfMonthFourth WeekOfMonth = "Fourth" + WeekOfMonthInvalid WeekOfMonth = "Invalid" + WeekOfMonthLast WeekOfMonth = "Last" + WeekOfMonthSecond WeekOfMonth = "Second" + WeekOfMonthThird WeekOfMonth = "Third" +) + +func PossibleValuesForWeekOfMonth() []string { + return []string{ + string(WeekOfMonthFirst), + string(WeekOfMonthFourth), + string(WeekOfMonthInvalid), + string(WeekOfMonthLast), + string(WeekOfMonthSecond), + string(WeekOfMonthThird), + } +} + +func parseWeekOfMonth(input string) (*WeekOfMonth, error) { + vals := map[string]WeekOfMonth{ + "first": WeekOfMonthFirst, + "fourth": WeekOfMonthFourth, + "invalid": WeekOfMonthInvalid, + "last": WeekOfMonthLast, + "second": WeekOfMonthSecond, + "third": WeekOfMonthThird, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WeekOfMonth(input) + return &out, nil +} + +type WorkloadType string + +const ( + WorkloadTypeAzureFileShare WorkloadType = "AzureFileShare" + WorkloadTypeAzureSqlDb WorkloadType = "AzureSqlDb" + WorkloadTypeClient WorkloadType = "Client" + WorkloadTypeExchange WorkloadType = "Exchange" + WorkloadTypeFileFolder WorkloadType = "FileFolder" + WorkloadTypeGenericDataSource WorkloadType = "GenericDataSource" + WorkloadTypeInvalid WorkloadType = "Invalid" + WorkloadTypeSAPAseDatabase WorkloadType = "SAPAseDatabase" + WorkloadTypeSAPHanaDatabase WorkloadType = "SAPHanaDatabase" + WorkloadTypeSQLDB WorkloadType = "SQLDB" + WorkloadTypeSQLDataBase WorkloadType = "SQLDataBase" + WorkloadTypeSharepoint WorkloadType = "Sharepoint" + WorkloadTypeSystemState WorkloadType = "SystemState" + WorkloadTypeVM WorkloadType = "VM" + WorkloadTypeVMwareVM WorkloadType = "VMwareVM" +) + +func PossibleValuesForWorkloadType() []string { + return []string{ + string(WorkloadTypeAzureFileShare), + string(WorkloadTypeAzureSqlDb), + string(WorkloadTypeClient), + string(WorkloadTypeExchange), + string(WorkloadTypeFileFolder), + string(WorkloadTypeGenericDataSource), + string(WorkloadTypeInvalid), + string(WorkloadTypeSAPAseDatabase), + string(WorkloadTypeSAPHanaDatabase), + string(WorkloadTypeSQLDB), + string(WorkloadTypeSQLDataBase), + string(WorkloadTypeSharepoint), + string(WorkloadTypeSystemState), + string(WorkloadTypeVM), + string(WorkloadTypeVMwareVM), + } +} + +func parseWorkloadType(input string) (*WorkloadType, error) { + vals := map[string]WorkloadType{ + "azurefileshare": WorkloadTypeAzureFileShare, + "azuresqldb": WorkloadTypeAzureSqlDb, + "client": WorkloadTypeClient, + "exchange": WorkloadTypeExchange, + "filefolder": WorkloadTypeFileFolder, + "genericdatasource": WorkloadTypeGenericDataSource, + "invalid": WorkloadTypeInvalid, + "sapasedatabase": WorkloadTypeSAPAseDatabase, + "saphanadatabase": WorkloadTypeSAPHanaDatabase, + "sqldb": WorkloadTypeSQLDB, + "sqldatabase": WorkloadTypeSQLDataBase, + "sharepoint": WorkloadTypeSharepoint, + "systemstate": WorkloadTypeSystemState, + "vm": WorkloadTypeVM, + "vmwarevm": WorkloadTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/id_backuppolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/id_backuppolicy.go new file mode 100644 index 000000000000..550057c6100b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/id_backuppolicy.go @@ -0,0 +1,140 @@ +package protectionpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = BackupPolicyId{} + +// BackupPolicyId is a struct representing the Resource ID for a Backup Policy +type BackupPolicyId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupPolicyName string +} + +// NewBackupPolicyID returns a new BackupPolicyId struct +func NewBackupPolicyID(subscriptionId string, resourceGroupName string, vaultName string, backupPolicyName string) BackupPolicyId { + return BackupPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupPolicyName: backupPolicyName, + } +} + +// ParseBackupPolicyID parses 'input' into a BackupPolicyId +func ParseBackupPolicyID(input string) (*BackupPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(BackupPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := BackupPolicyId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + if id.BackupPolicyName, ok = parsed.Parsed["backupPolicyName"]; !ok { + return nil, fmt.Errorf("the segment 'backupPolicyName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseBackupPolicyIDInsensitively parses 'input' case-insensitively into a BackupPolicyId +// note: this method should only be used for API response data and not user input +func ParseBackupPolicyIDInsensitively(input string) (*BackupPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(BackupPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := BackupPolicyId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.VaultName, ok = parsed.Parsed["vaultName"]; !ok { + return nil, fmt.Errorf("the segment 'vaultName' was not found in the resource id %q", input) + } + + if id.BackupPolicyName, ok = parsed.Parsed["backupPolicyName"]; !ok { + return nil, fmt.Errorf("the segment 'backupPolicyName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateBackupPolicyID checks that 'input' can be parsed as a Backup Policy ID +func ValidateBackupPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Policy ID +func (id BackupPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Policy ID +func (id BackupPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupPolicies", "backupPolicies", "backupPolicies"), + resourceids.UserSpecifiedSegment("backupPolicyName", "backupPolicyValue"), + } +} + +// String returns a human-readable description of this Backup Policy ID +func (id BackupPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Policy Name: %q", id.BackupPolicyName), + } + return fmt.Sprintf("Backup Policy (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_createorupdate_autorest.go new file mode 100644 index 000000000000..a10287d2ffc6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_createorupdate_autorest.go @@ -0,0 +1,69 @@ +package protectionpolicies + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *ProtectionPolicyResource +} + +// CreateOrUpdate ... +func (c ProtectionPoliciesClient) CreateOrUpdate(ctx context.Context, id BackupPolicyId, input ProtectionPolicyResource) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c ProtectionPoliciesClient) preparerForCreateOrUpdate(ctx context.Context, id BackupPolicyId, input ProtectionPolicyResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c ProtectionPoliciesClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_delete_autorest.go new file mode 100644 index 000000000000..d8310df327c7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_delete_autorest.go @@ -0,0 +1,78 @@ +package protectionpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c ProtectionPoliciesClient) Delete(ctx context.Context, id BackupPolicyId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ProtectionPoliciesClient) DeleteThenPoll(ctx context.Context, id BackupPolicyId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} + +// preparerForDelete prepares the Delete request. +func (c ProtectionPoliciesClient) preparerForDelete(ctx context.Context, id BackupPolicyId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForDelete sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (c ProtectionPoliciesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_get_autorest.go new file mode 100644 index 000000000000..bd3aabebfe79 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/method_get_autorest.go @@ -0,0 +1,68 @@ +package protectionpolicies + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *ProtectionPolicyResource +} + +// Get ... +func (c ProtectionPoliciesClient) Get(ctx context.Context, id BackupPolicyId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ProtectionPoliciesClient) preparerForGet(ctx context.Context, id BackupPolicyId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ProtectionPoliciesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azurefileshareprotectionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azurefileshareprotectionpolicy.go new file mode 100644 index 000000000000..9b4b6abeea3f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azurefileshareprotectionpolicy.go @@ -0,0 +1,83 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureFileShareProtectionPolicy{} + +type AzureFileShareProtectionPolicy struct { + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + TimeZone *string `json:"timeZone,omitempty"` + WorkLoadType *WorkloadType `json:"workLoadType,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureFileShareProtectionPolicy{} + +func (s AzureFileShareProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureStorage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureFileShareProtectionPolicy{} + +func (s *AzureFileShareProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureFileShareProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureFileShareProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.TimeZone = decoded.TimeZone + s.WorkLoadType = decoded.WorkLoadType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureFileShareProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureFileShareProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'AzureFileShareProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go new file mode 100644 index 000000000000..abea4b36410e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go @@ -0,0 +1,89 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureIaaSVMProtectionPolicy{} + +type AzureIaaSVMProtectionPolicy struct { + InstantRPDetails *InstantRPAdditionalDetails `json:"instantRPDetails,omitempty"` + InstantRpRetentionRangeInDays *int64 `json:"instantRpRetentionRangeInDays,omitempty"` + PolicyType *IAASVMPolicyType `json:"policyType,omitempty"` + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureIaaSVMProtectionPolicy{} + +func (s AzureIaaSVMProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureIaasVM" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureIaaSVMProtectionPolicy{} + +func (s *AzureIaaSVMProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureIaaSVMProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureIaaSVMProtectionPolicy: %+v", err) + } + + s.InstantRPDetails = decoded.InstantRPDetails + s.InstantRpRetentionRangeInDays = decoded.InstantRpRetentionRangeInDays + s.PolicyType = decoded.PolicyType + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.TieringPolicy = decoded.TieringPolicy + s.TimeZone = decoded.TimeZone + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureIaaSVMProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureIaaSVMProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'AzureIaaSVMProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azuresqlprotectionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azuresqlprotectionpolicy.go new file mode 100644 index 000000000000..5a691310aaf5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azuresqlprotectionpolicy.go @@ -0,0 +1,70 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureSqlProtectionPolicy{} + +type AzureSqlProtectionPolicy struct { + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureSqlProtectionPolicy{} + +func (s AzureSqlProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureSql" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureSqlProtectionPolicy{} + +func (s *AzureSqlProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureSqlProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureSqlProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureSqlProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureSqlProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go new file mode 100644 index 000000000000..4ad1179dc7cb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go @@ -0,0 +1,46 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureVMWorkloadProtectionPolicy{} + +type AzureVMWorkloadProtectionPolicy struct { + MakePolicyConsistent *bool `json:"makePolicyConsistent,omitempty"` + Settings *Settings `json:"settings,omitempty"` + SubProtectionPolicy *[]SubProtectionPolicy `json:"subProtectionPolicy,omitempty"` + WorkLoadType *WorkloadType `json:"workLoadType,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadProtectionPolicy{} + +func (s AzureVMWorkloadProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureWorkload" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyretentionformat.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyretentionformat.go new file mode 100644 index 000000000000..f2f8a9c3693a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyretentionformat.go @@ -0,0 +1,8 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DailyRetentionFormat struct { + DaysOfTheMonth *[]Day `json:"daysOfTheMonth,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyretentionschedule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyretentionschedule.go new file mode 100644 index 000000000000..40dc38fbcdad --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyretentionschedule.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DailyRetentionSchedule struct { + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyschedule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyschedule.go new file mode 100644 index 000000000000..88826749b256 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_dailyschedule.go @@ -0,0 +1,8 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DailySchedule struct { + ScheduleRunTimes *[]string `json:"scheduleRunTimes,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_day.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_day.go new file mode 100644 index 000000000000..ca922f3cfe20 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_day.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Day struct { + Date *int64 `json:"date,omitempty"` + IsLast *bool `json:"isLast,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_genericprotectionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_genericprotectionpolicy.go new file mode 100644 index 000000000000..c893e4e80513 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_genericprotectionpolicy.go @@ -0,0 +1,45 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = GenericProtectionPolicy{} + +type GenericProtectionPolicy struct { + FabricName *string `json:"fabricName,omitempty"` + SubProtectionPolicy *[]SubProtectionPolicy `json:"subProtectionPolicy,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = GenericProtectionPolicy{} + +func (s GenericProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper GenericProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "GenericProtectionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericProtectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_hourlyschedule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_hourlyschedule.go new file mode 100644 index 000000000000..8e573c02a5c6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_hourlyschedule.go @@ -0,0 +1,28 @@ +package protectionpolicies + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HourlySchedule struct { + Interval *int64 `json:"interval,omitempty"` + ScheduleWindowDuration *int64 `json:"scheduleWindowDuration,omitempty"` + ScheduleWindowStartTime *string `json:"scheduleWindowStartTime,omitempty"` +} + +func (o *HourlySchedule) GetScheduleWindowStartTimeAsTime() (*time.Time, error) { + if o.ScheduleWindowStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduleWindowStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *HourlySchedule) SetScheduleWindowStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduleWindowStartTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_instantrpadditionaldetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_instantrpadditionaldetails.go new file mode 100644 index 000000000000..ea9cd7a24da8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_instantrpadditionaldetails.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstantRPAdditionalDetails struct { + AzureBackupRGNamePrefix *string `json:"azureBackupRGNamePrefix,omitempty"` + AzureBackupRGNameSuffix *string `json:"azureBackupRGNameSuffix,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_logschedulepolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_logschedulepolicy.go new file mode 100644 index 000000000000..8f2cae119012 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_logschedulepolicy.go @@ -0,0 +1,41 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = LogSchedulePolicy{} + +type LogSchedulePolicy struct { + ScheduleFrequencyInMins *int64 `json:"scheduleFrequencyInMins,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = LogSchedulePolicy{} + +func (s LogSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper LogSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LogSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LogSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "LogSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LogSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_longtermretentionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_longtermretentionpolicy.go new file mode 100644 index 000000000000..50f80900d4e0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_longtermretentionpolicy.go @@ -0,0 +1,44 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RetentionPolicy = LongTermRetentionPolicy{} + +type LongTermRetentionPolicy struct { + DailySchedule *DailyRetentionSchedule `json:"dailySchedule,omitempty"` + MonthlySchedule *MonthlyRetentionSchedule `json:"monthlySchedule,omitempty"` + WeeklySchedule *WeeklyRetentionSchedule `json:"weeklySchedule,omitempty"` + YearlySchedule *YearlyRetentionSchedule `json:"yearlySchedule,omitempty"` + + // Fields inherited from RetentionPolicy +} + +var _ json.Marshaler = LongTermRetentionPolicy{} + +func (s LongTermRetentionPolicy) MarshalJSON() ([]byte, error) { + type wrapper LongTermRetentionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LongTermRetentionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LongTermRetentionPolicy: %+v", err) + } + decoded["retentionPolicyType"] = "LongTermRetentionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LongTermRetentionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_longtermschedulepolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_longtermschedulepolicy.go new file mode 100644 index 000000000000..06d19a60ab2e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_longtermschedulepolicy.go @@ -0,0 +1,40 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = LongTermSchedulePolicy{} + +type LongTermSchedulePolicy struct { + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = LongTermSchedulePolicy{} + +func (s LongTermSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper LongTermSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LongTermSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LongTermSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "LongTermSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LongTermSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_mabprotectionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_mabprotectionpolicy.go new file mode 100644 index 000000000000..4178653c4e68 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_mabprotectionpolicy.go @@ -0,0 +1,79 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = MabProtectionPolicy{} + +type MabProtectionPolicy struct { + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = MabProtectionPolicy{} + +func (s MabProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper MabProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "MAB" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &MabProtectionPolicy{} + +func (s *MabProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias MabProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into MabProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MabProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'MabProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'MabProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_monthlyretentionschedule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_monthlyretentionschedule.go new file mode 100644 index 000000000000..4ceda36d8756 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_monthlyretentionschedule.go @@ -0,0 +1,12 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonthlyRetentionSchedule struct { + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionScheduleDaily *DailyRetentionFormat `json:"retentionScheduleDaily,omitempty"` + RetentionScheduleFormatType *RetentionScheduleFormat `json:"retentionScheduleFormatType,omitempty"` + RetentionScheduleWeekly *WeeklyRetentionFormat `json:"retentionScheduleWeekly,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_protectionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_protectionpolicy.go new file mode 100644 index 000000000000..67771822a938 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_protectionpolicy.go @@ -0,0 +1,88 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionPolicy interface { +} + +func unmarshalProtectionPolicyImplementation(input []byte) (ProtectionPolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["backupManagementType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureStorage") { + var out AzureFileShareProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaasVM") { + var out AzureIaaSVMProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSql") { + var out AzureSqlProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkload") { + var out AzureVMWorkloadProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericProtectionPolicy") { + var out GenericProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MAB") { + var out MabProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabProtectionPolicy: %+v", err) + } + return out, nil + } + + type RawProtectionPolicyImpl struct { + Type string `json:"-"` + Values map[string]interface{} `json:"-"` + } + out := RawProtectionPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_protectionpolicyresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_protectionpolicyresource.go new file mode 100644 index 000000000000..03bda4d0a126 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_protectionpolicyresource.go @@ -0,0 +1,50 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionPolicyResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionPolicy `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionPolicyResource{} + +func (s *ProtectionPolicyResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionPolicyResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionPolicyResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionPolicyResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionPolicyResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_retentionduration.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_retentionduration.go new file mode 100644 index 000000000000..4b77b5e2f239 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_retentionduration.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionDuration struct { + Count *int64 `json:"count,omitempty"` + DurationType *RetentionDurationType `json:"durationType,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_retentionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_retentionpolicy.go new file mode 100644 index 000000000000..00c866c5775c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_retentionpolicy.go @@ -0,0 +1,56 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicy interface { +} + +func unmarshalRetentionPolicyImplementation(input []byte) (RetentionPolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling RetentionPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["retentionPolicyType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "LongTermRetentionPolicy") { + var out LongTermRetentionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LongTermRetentionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleRetentionPolicy") { + var out SimpleRetentionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleRetentionPolicy: %+v", err) + } + return out, nil + } + + type RawRetentionPolicyImpl struct { + Type string `json:"-"` + Values map[string]interface{} `json:"-"` + } + out := RawRetentionPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_schedulepolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_schedulepolicy.go new file mode 100644 index 000000000000..c5f328933935 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_schedulepolicy.go @@ -0,0 +1,72 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchedulePolicy interface { +} + +func unmarshalSchedulePolicyImplementation(input []byte) (SchedulePolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SchedulePolicy into map[string]interface: %+v", err) + } + + value, ok := temp["schedulePolicyType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "LogSchedulePolicy") { + var out LogSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LogSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "LongTermSchedulePolicy") { + var out LongTermSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LongTermSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleSchedulePolicy") { + var out SimpleSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleSchedulePolicyV2") { + var out SimpleSchedulePolicyV2 + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleSchedulePolicyV2: %+v", err) + } + return out, nil + } + + type RawSchedulePolicyImpl struct { + Type string `json:"-"` + Values map[string]interface{} `json:"-"` + } + out := RawSchedulePolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_settings.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_settings.go new file mode 100644 index 000000000000..585e96708fc0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_settings.go @@ -0,0 +1,10 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Settings struct { + IsCompression *bool `json:"isCompression,omitempty"` + Issqlcompression *bool `json:"issqlcompression,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleretentionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleretentionpolicy.go new file mode 100644 index 000000000000..37edb09a9560 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleretentionpolicy.go @@ -0,0 +1,41 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RetentionPolicy = SimpleRetentionPolicy{} + +type SimpleRetentionPolicy struct { + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + + // Fields inherited from RetentionPolicy +} + +var _ json.Marshaler = SimpleRetentionPolicy{} + +func (s SimpleRetentionPolicy) MarshalJSON() ([]byte, error) { + type wrapper SimpleRetentionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleRetentionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleRetentionPolicy: %+v", err) + } + decoded["retentionPolicyType"] = "SimpleRetentionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleRetentionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleschedulepolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleschedulepolicy.go new file mode 100644 index 000000000000..117247120b63 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleschedulepolicy.go @@ -0,0 +1,45 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = SimpleSchedulePolicy{} + +type SimpleSchedulePolicy struct { + HourlySchedule *HourlySchedule `json:"hourlySchedule,omitempty"` + ScheduleRunDays *[]DayOfWeek `json:"scheduleRunDays,omitempty"` + ScheduleRunFrequency *ScheduleRunType `json:"scheduleRunFrequency,omitempty"` + ScheduleRunTimes *[]string `json:"scheduleRunTimes,omitempty"` + ScheduleWeeklyFrequency *int64 `json:"scheduleWeeklyFrequency,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = SimpleSchedulePolicy{} + +func (s SimpleSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper SimpleSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "SimpleSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleschedulepolicyv2.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleschedulepolicyv2.go new file mode 100644 index 000000000000..f522d8d71849 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_simpleschedulepolicyv2.go @@ -0,0 +1,44 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = SimpleSchedulePolicyV2{} + +type SimpleSchedulePolicyV2 struct { + DailySchedule *DailySchedule `json:"dailySchedule,omitempty"` + HourlySchedule *HourlySchedule `json:"hourlySchedule,omitempty"` + ScheduleRunFrequency *ScheduleRunType `json:"scheduleRunFrequency,omitempty"` + WeeklySchedule *WeeklySchedule `json:"weeklySchedule,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = SimpleSchedulePolicyV2{} + +func (s SimpleSchedulePolicyV2) MarshalJSON() ([]byte, error) { + type wrapper SimpleSchedulePolicyV2 + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleSchedulePolicyV2: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleSchedulePolicyV2: %+v", err) + } + decoded["schedulePolicyType"] = "SimpleSchedulePolicyV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleSchedulePolicyV2: %+v", err) + } + + return encoded, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_subprotectionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_subprotectionpolicy.go new file mode 100644 index 000000000000..bcf1c32ee701 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_subprotectionpolicy.go @@ -0,0 +1,51 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubProtectionPolicy struct { + PolicyType *PolicyType `json:"policyType,omitempty"` + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` +} + +var _ json.Unmarshaler = &SubProtectionPolicy{} + +func (s *SubProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias SubProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into SubProtectionPolicy: %+v", err) + } + + s.PolicyType = decoded.PolicyType + s.TieringPolicy = decoded.TieringPolicy + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SubProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'SubProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'SubProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_tieringpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_tieringpolicy.go new file mode 100644 index 000000000000..51a5c8b97f07 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_tieringpolicy.go @@ -0,0 +1,10 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TieringPolicy struct { + Duration *int64 `json:"duration,omitempty"` + DurationType *RetentionDurationType `json:"durationType,omitempty"` + TieringMode *TieringMode `json:"tieringMode,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyretentionformat.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyretentionformat.go new file mode 100644 index 000000000000..082fcf7abe15 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyretentionformat.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WeeklyRetentionFormat struct { + DaysOfTheWeek *[]DayOfWeek `json:"daysOfTheWeek,omitempty"` + WeeksOfTheMonth *[]WeekOfMonth `json:"weeksOfTheMonth,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyretentionschedule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyretentionschedule.go new file mode 100644 index 000000000000..cde2551554dd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyretentionschedule.go @@ -0,0 +1,10 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WeeklyRetentionSchedule struct { + DaysOfTheWeek *[]DayOfWeek `json:"daysOfTheWeek,omitempty"` + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyschedule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyschedule.go new file mode 100644 index 000000000000..f3005f7015ff --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_weeklyschedule.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WeeklySchedule struct { + ScheduleRunDays *[]DayOfWeek `json:"scheduleRunDays,omitempty"` + ScheduleRunTimes *[]string `json:"scheduleRunTimes,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_yearlyretentionschedule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_yearlyretentionschedule.go new file mode 100644 index 000000000000..8d300368ef54 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/model_yearlyretentionschedule.go @@ -0,0 +1,13 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type YearlyRetentionSchedule struct { + MonthsOfYear *[]MonthOfYear `json:"monthsOfYear,omitempty"` + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionScheduleDaily *DailyRetentionFormat `json:"retentionScheduleDaily,omitempty"` + RetentionScheduleFormatType *RetentionScheduleFormat `json:"retentionScheduleFormatType,omitempty"` + RetentionScheduleWeekly *WeeklyRetentionFormat `json:"retentionScheduleWeekly,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/version.go new file mode 100644 index 000000000000..5c63d5eef44a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies/version.go @@ -0,0 +1,12 @@ +package protectionpolicies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protectionpolicies/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index f3e1cec131e2..bef005d11107 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -469,8 +469,13 @@ github.com/hashicorp/go-azure-sdk/resource-manager/privatedns/2018-09-01/virtual github.com/hashicorp/go-azure-sdk/resource-manager/purview/2021-07-01/account github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2022-10-01/vaultcertificates github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2022-10-01/vaults +github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotectableitems +github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupprotecteditems github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupresourcestorageconfigsnoncrr github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/backupresourcevaultconfigs +github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems +github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectioncontainers +github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protectionpolicies github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationfabrics github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationnetworkmappings github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationpolicies From 38ed58000d53b503e7043bf4582c749f0d7fc083 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 6 Apr 2023 19:28:52 -0700 Subject: [PATCH 2/5] Test fixes --- .../backup_policy_file_share_resource.go | 17 +++++------ .../backup_policy_vm_resource.go | 30 ++++++++++--------- .../backup_policy_vm_workload_resource.go | 3 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/internal/services/recoveryservices/backup_policy_file_share_resource.go b/internal/services/recoveryservices/backup_policy_file_share_resource.go index 04210d7ebff8..7627fd60bc66 100644 --- a/internal/services/recoveryservices/backup_policy_file_share_resource.go +++ b/internal/services/recoveryservices/backup_policy_file_share_resource.go @@ -227,11 +227,7 @@ func resourceBackupProtectionPolicyFileShareDelete(d *pluginsdk.ResourceData, me return fmt.Errorf("deleting %s: %+v", *id, err) } - if _, err := resourceBackupProtectionPolicyFileShareWaitForDeletion(ctx, client, *id, d); err != nil { - return err - } - - return nil + return resourceBackupProtectionPolicyFileShareWaitForDeletion(ctx, client, *id, d) } func expandBackupProtectionPolicyFileShareSchedule(d *pluginsdk.ResourceData, times []string) *protectionpolicies.SimpleSchedulePolicy { @@ -370,7 +366,8 @@ func flattenBackupProtectionPolicyFileShareSchedule(schedule protectionpolicies. block["frequency"] = string(pointer.From(schedule.ScheduleRunFrequency)) if times := schedule.ScheduleRunTimes; times != nil && len(*times) > 0 { - block["time"] = (*times)[0] + policyTime, _ := time.Parse(time.RFC3339, (*times)[0]) + block["time"] = policyTime.Format("15:04") } return []interface{}{block} @@ -491,7 +488,7 @@ func resourceBackupProtectionPolicyFileShareWaitForUpdate(ctx context.Context, c return resp.(protectionpolicies.ProtectionPolicyResource), nil } -func resourceBackupProtectionPolicyFileShareWaitForDeletion(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) (protectionpolicies.ProtectionPolicyResource, error) { +func resourceBackupProtectionPolicyFileShareWaitForDeletion(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) error { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, @@ -501,12 +498,12 @@ func resourceBackupProtectionPolicyFileShareWaitForDeletion(ctx context.Context, Timeout: d.Timeout(pluginsdk.TimeoutDelete), } - resp, err := state.WaitForStateContext(ctx) + _, err := state.WaitForStateContext(ctx) if err != nil { - return resp.(protectionpolicies.ProtectionPolicyResource), fmt.Errorf("waiting for delete to finish for %s: %+v", id, err) + return fmt.Errorf("waiting for delete to finish for %s: %+v", id, err) } - return resp.(protectionpolicies.ProtectionPolicyResource), nil + return nil } func resourceBackupProtectionPolicyFileShareRefreshFunc(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId) pluginsdk.StateRefreshFunc { diff --git a/internal/services/recoveryservices/backup_policy_vm_resource.go b/internal/services/recoveryservices/backup_policy_vm_resource.go index 2b1aa331ab60..d883ed71f686 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource.go @@ -172,8 +172,7 @@ func resourceBackupProtectionPolicyVMCreateUpdate(d *pluginsdk.ResourceData, met return fmt.Errorf("creating/updating %s: %+v", id, err) } - _, err = resourceBackupProtectionPolicyVMWaitForUpdate(ctx, client, id, d) - if err != nil { + if err = resourceBackupProtectionPolicyVMWaitForUpdate(ctx, client, id, d); err != nil { return err } @@ -290,7 +289,7 @@ func resourceBackupProtectionPolicyVMDelete(d *pluginsdk.ResourceData, meta inte return fmt.Errorf("deleting %s: %+v", *id, err) } - if _, err := resourceBackupProtectionPolicyVMWaitForDeletion(ctx, client, *id, d); err != nil { + if err = resourceBackupProtectionPolicyVMWaitForDeletion(ctx, client, *id, d); err != nil { return err } @@ -544,7 +543,8 @@ func flattenBackupProtectionPolicyVMSchedule(schedule protectionpolicies.SimpleS block["frequency"] = string(pointer.From(schedule.ScheduleRunFrequency)) if times := schedule.ScheduleRunTimes; times != nil && len(*times) > 0 { - block["time"] = (*times)[0] + policyTime, _ := time.Parse(time.RFC3339, (*times)[0]) + block["time"] = policyTime.Format("15:04") } if days := schedule.ScheduleRunDays; days != nil { @@ -581,7 +581,8 @@ func flattenBackupProtectionPolicyVMScheduleV2(schedule protectionpolicies.Simpl case protectionpolicies.ScheduleRunTypeDaily: schedule := schedule.DailySchedule if times := schedule.ScheduleRunTimes; times != nil && len(*times) > 0 { - block["time"] = (*times)[0] + policyTime, _ := time.Parse(time.RFC3339, (*times)[0]) + block["time"] = policyTime.Format("15:04") } case protectionpolicies.ScheduleRunTypeWeekly: schedule := schedule.WeeklySchedule @@ -594,7 +595,8 @@ func flattenBackupProtectionPolicyVMScheduleV2(schedule protectionpolicies.Simpl } if times := schedule.ScheduleRunTimes; times != nil && len(*times) > 0 { - block["time"] = (*times)[0] + policyTime, _ := time.Parse(time.RFC3339, (*times)[0]) + block["time"] = policyTime.Format("15:04") } default: } @@ -694,7 +696,7 @@ func flattenBackupProtectionPolicyVMRetentionWeeklyFormat(retention *protectionp return weekdays, weeks } -func resourceBackupProtectionPolicyVMWaitForUpdate(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) (protectionpolicies.ProtectionPolicyResource, error) { +func resourceBackupProtectionPolicyVMWaitForUpdate(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) error { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, @@ -709,15 +711,15 @@ func resourceBackupProtectionPolicyVMWaitForUpdate(ctx context.Context, client * state.Timeout = d.Timeout(pluginsdk.TimeoutUpdate) } - resp, err := state.WaitForStateContext(ctx) + _, err := state.WaitForStateContext(ctx) if err != nil { - return resp.(protectionpolicies.ProtectionPolicyResource), fmt.Errorf("waiting for %s to provision: %+v", id, err) + return fmt.Errorf("waiting for %s to provision: %+v", id, err) } - return resp.(protectionpolicies.ProtectionPolicyResource), nil + return nil } -func resourceBackupProtectionPolicyVMWaitForDeletion(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) (protectionpolicies.ProtectionPolicyResource, error) { +func resourceBackupProtectionPolicyVMWaitForDeletion(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) error { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, @@ -727,12 +729,12 @@ func resourceBackupProtectionPolicyVMWaitForDeletion(ctx context.Context, client Timeout: d.Timeout(pluginsdk.TimeoutDelete), } - resp, err := state.WaitForStateContext(ctx) + _, err := state.WaitForStateContext(ctx) if err != nil { - return resp.(protectionpolicies.ProtectionPolicyResource), fmt.Errorf("waiting for %s to provision: %+v", id, err) + return fmt.Errorf("waiting for %s to provision: %+v", id, err) } - return resp.(protectionpolicies.ProtectionPolicyResource), nil + return nil } func resourceBackupProtectionPolicyVMRefreshFunc(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId) pluginsdk.StateRefreshFunc { diff --git a/internal/services/recoveryservices/backup_policy_vm_workload_resource.go b/internal/services/recoveryservices/backup_policy_vm_workload_resource.go index 77f63f2c9d59..7c68661fe546 100644 --- a/internal/services/recoveryservices/backup_policy_vm_workload_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_workload_resource.go @@ -747,7 +747,8 @@ func flattenBackupProtectionPolicyVMWorkloadSchedulePolicy(input protectionpolic backupBlock.Frequency = string(pointer.From(simpleSchedulePolicy.ScheduleRunFrequency)) if times := simpleSchedulePolicy.ScheduleRunTimes; times != nil && len(*times) > 0 { - backupBlock.Time = (*times)[0] + policyTime, _ := time.Parse(time.RFC3339, (*times)[0]) + backupBlock.Time = policyTime.Format("15:04") } if days := simpleSchedulePolicy.ScheduleRunDays; days != nil { From 80d5a8f305da3767636f09c9853460c555a99556 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 7 Apr 2023 08:59:38 -0700 Subject: [PATCH 3/5] more test fixes --- .../backup_policy_file_share_resource.go | 11 +++++------ .../recoveryservices/backup_policy_vm_resource.go | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/services/recoveryservices/backup_policy_file_share_resource.go b/internal/services/recoveryservices/backup_policy_file_share_resource.go index 7627fd60bc66..ef2cabc24d05 100644 --- a/internal/services/recoveryservices/backup_policy_file_share_resource.go +++ b/internal/services/recoveryservices/backup_policy_file_share_resource.go @@ -126,8 +126,7 @@ func resourceBackupProtectionPolicyFileShareCreateUpdate(d *pluginsdk.ResourceDa return fmt.Errorf("creating/updating %s: %+v", id, err) } - _, err = resourceBackupProtectionPolicyFileShareWaitForUpdate(ctx, client, id, d) - if err != nil { + if err = resourceBackupProtectionPolicyFileShareWaitForUpdate(ctx, client, id, d); err != nil { return err } @@ -465,7 +464,7 @@ func flattenBackupProtectionPolicyFileShareRetentionWeeklyFormat(retention *prot return weekdays, weeks } -func resourceBackupProtectionPolicyFileShareWaitForUpdate(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) (protectionpolicies.ProtectionPolicyResource, error) { +func resourceBackupProtectionPolicyFileShareWaitForUpdate(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) error { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, @@ -480,12 +479,12 @@ func resourceBackupProtectionPolicyFileShareWaitForUpdate(ctx context.Context, c state.Timeout = d.Timeout(pluginsdk.TimeoutUpdate) } - resp, err := state.WaitForStateContext(ctx) + _, err := state.WaitForStateContext(ctx) if err != nil { - return resp.(protectionpolicies.ProtectionPolicyResource), fmt.Errorf("waiting for update %s: %+v", id, err) + return fmt.Errorf("waiting for update %s: %+v", id, err) } - return resp.(protectionpolicies.ProtectionPolicyResource), nil + return nil } func resourceBackupProtectionPolicyFileShareWaitForDeletion(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) error { diff --git a/internal/services/recoveryservices/backup_policy_vm_resource.go b/internal/services/recoveryservices/backup_policy_vm_resource.go index d883ed71f686..a769cb023db9 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource.go @@ -576,7 +576,8 @@ func flattenBackupProtectionPolicyVMScheduleV2(schedule protectionpolicies.Simpl } if schedule.ScheduleWindowStartTime != nil { - block["time"] = schedule.ScheduleWindowStartTime + policyTime, _ := time.Parse(time.RFC3339, pointer.From(schedule.ScheduleWindowStartTime)) + block["time"] = policyTime.Format("15:04") } case protectionpolicies.ScheduleRunTypeDaily: schedule := schedule.DailySchedule From e9799d6a4ea648e9aca02542f5431aa4e79cb3ec Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 7 Apr 2023 10:07:19 -0700 Subject: [PATCH 4/5] test fixes --- .../backup_policy_file_share_resource.go | 10 +++++--- .../backup_protected_vm_resource.go | 25 ++++++++----------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/internal/services/recoveryservices/backup_policy_file_share_resource.go b/internal/services/recoveryservices/backup_policy_file_share_resource.go index ef2cabc24d05..be352e2dccfc 100644 --- a/internal/services/recoveryservices/backup_policy_file_share_resource.go +++ b/internal/services/recoveryservices/backup_policy_file_share_resource.go @@ -294,11 +294,13 @@ func expandBackupProtectionPolicyFileShareRetentionMonthly(d *pluginsdk.Resource block := rb[0].(map[string]interface{}) retention := protectionpolicies.MonthlyRetentionSchedule{ - RetentionScheduleDaily: nil, // and this is always nil.. - RetentionScheduleWeekly: expandBackupProtectionPolicyFileShareRetentionWeeklyFormat(block), - RetentionTimes: ×, + RetentionScheduleFormatType: pointer.To(protectionpolicies.RetentionScheduleFormatWeekly), + RetentionScheduleDaily: nil, // and this is always nil.. + RetentionScheduleWeekly: expandBackupProtectionPolicyFileShareRetentionWeeklyFormat(block), + RetentionTimes: ×, RetentionDuration: &protectionpolicies.RetentionDuration{ - Count: pointer.To(int64(block["count"].(int))), + Count: pointer.To(int64(block["count"].(int))), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeMonths), }, } diff --git a/internal/services/recoveryservices/backup_protected_vm_resource.go b/internal/services/recoveryservices/backup_protected_vm_resource.go index 5e6bf318e98e..7f54928b510c 100644 --- a/internal/services/recoveryservices/backup_protected_vm_resource.go +++ b/internal/services/recoveryservices/backup_protected_vm_resource.go @@ -113,8 +113,7 @@ func resourceRecoveryServicesBackupProtectedVMCreateUpdate(d *pluginsdk.Resource return fmt.Errorf("creating/updating Azure Backup Protected VM %q (Resource Group %q): %+v", protectedItemName, resourceGroup, err) } - _, err = resourceRecoveryServicesBackupProtectedVMWaitForStateCreateUpdate(ctx, client, id, d) - if err != nil { + if err = resourceRecoveryServicesBackupProtectedVMWaitForStateCreateUpdate(ctx, client, id, d); err != nil { return err } @@ -205,14 +204,14 @@ func resourceRecoveryServicesBackupProtectedVMDelete(d *pluginsdk.ResourceData, return err } - if _, err := resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx, client, opResultClient, *id, parsedLocation.Path["backupOperationResults"], d); err != nil { + if err = resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx, client, opResultClient, *id, parsedLocation.Path["backupOperationResults"], d); err != nil { return err } return nil } -func resourceRecoveryServicesBackupProtectedVMWaitForStateCreateUpdate(ctx context.Context, client *protecteditems.ProtectedItemsClient, id protecteditems.ProtectedItemId, d *pluginsdk.ResourceData) (backup.ProtectedItemResource, error) { +func resourceRecoveryServicesBackupProtectedVMWaitForStateCreateUpdate(ctx context.Context, client *protecteditems.ProtectedItemsClient, id protecteditems.ProtectedItemId, d *pluginsdk.ResourceData) error { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, @@ -227,16 +226,15 @@ func resourceRecoveryServicesBackupProtectedVMWaitForStateCreateUpdate(ctx conte state.Timeout = d.Timeout(pluginsdk.TimeoutUpdate) } - resp, err := state.WaitForStateContext(ctx) + _, err := state.WaitForStateContext(ctx) if err != nil { - i, _ := resp.(backup.ProtectedItemResource) - return i, fmt.Errorf("waiting for %s to provision: %+v", id, err) + return fmt.Errorf("waiting for %s to provision: %+v", id, err) } - return resp.(backup.ProtectedItemResource), nil + return nil } -func resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx context.Context, client *protecteditems.ProtectedItemsClient, opResultClient *backup.OperationResultsClient, id protecteditems.ProtectedItemId, operationId string, d *pluginsdk.ResourceData) (backup.ProtectedItemResource, error) { +func resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx context.Context, client *protecteditems.ProtectedItemsClient, opResultClient *backup.OperationResultsClient, id protecteditems.ProtectedItemId, operationId string, d *pluginsdk.ResourceData) error { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, Delay: 10 * time.Second, @@ -267,10 +265,9 @@ func resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx context.Contex Timeout: d.Timeout(pluginsdk.TimeoutDelete), } - resp, err := state.WaitForStateContext(ctx) + _, err := state.WaitForStateContext(ctx) if err != nil { - i, _ := resp.(backup.ProtectedItemResource) - return i, fmt.Errorf("waiting for %s: %+v", id, err) + return fmt.Errorf("waiting for %s: %+v", id, err) } // we should also wait for the operation to complete, or it will fail when creating a new backup vm with the same vm in different vault immediately. @@ -292,10 +289,10 @@ func resourceRecoveryServicesBackupProtectedVMWaitForDeletion(ctx context.Contex _, err = opState.WaitForStateContext(ctx) if err != nil { - return resp.(backup.ProtectedItemResource), fmt.Errorf("waiting for the Recovery Service Protected Item operation to be deleted for %s: %+v", id, err) + return fmt.Errorf("waiting for the Recovery Service Protected Item operation to be deleted for %s: %+v", id, err) } - return resp.(backup.ProtectedItemResource), nil + return nil } func resourceRecoveryServicesBackupProtectedVMRefreshFunc(ctx context.Context, client *protecteditems.ProtectedItemsClient, id protecteditems.ProtectedItemId) pluginsdk.StateRefreshFunc { From 7d22cb6a98c0a393851da058316378d5dcc52cee Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 7 Apr 2023 15:40:02 -0700 Subject: [PATCH 5/5] lint --- .../recoveryservices/backup_policy_file_share_resource.go | 2 +- .../recoveryservices/backup_protected_file_share_resource.go | 2 +- .../recoveryservices/backup_protected_vm_resource_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/recoveryservices/backup_policy_file_share_resource.go b/internal/services/recoveryservices/backup_policy_file_share_resource.go index be352e2dccfc..aa0a40f0f514 100644 --- a/internal/services/recoveryservices/backup_policy_file_share_resource.go +++ b/internal/services/recoveryservices/backup_policy_file_share_resource.go @@ -91,7 +91,7 @@ func resourceBackupProtectionPolicyFileShareCreateUpdate(d *pluginsdk.ResourceDa if err != nil { return fmt.Errorf("generating time from %q for %s: %+v", timeOfDay, id, err) } - times := append(append(make([]string, 0), date.Time{Time: dateOfDay}.String())) + times := append(make([]string, 0), date.Time{Time: dateOfDay}.String()) if d.IsNewResource() { existing, err := client.Get(ctx, id) diff --git a/internal/services/recoveryservices/backup_protected_file_share_resource.go b/internal/services/recoveryservices/backup_protected_file_share_resource.go index e233f770b08f..c6b2132ed7ef 100644 --- a/internal/services/recoveryservices/backup_protected_file_share_resource.go +++ b/internal/services/recoveryservices/backup_protected_file_share_resource.go @@ -122,7 +122,7 @@ func resourceBackupProtectedFileShareCreateUpdate(d *pluginsdk.ResourceData, met // it cannot be listed by Backup Protectable Items - List API after the storage account is registered with a RSV). // After confirming with the service team, whenever new file shares are added, we need to run an 'inquire' API. but inquiry APIs are long running APIs and hence can't be included in GET API's (Backup Protectable Items - List) response. // Therefore, add 'inquire' API to inquire all unprotected files shares under a storage account to fix this usecase. - respContainer, err := protectionContainerClient.Inquire(ctx, protectionContainerId, protectioncontainers.InquireOperationOptions{pointer.To(filter)}) + respContainer, err := protectionContainerClient.Inquire(ctx, protectionContainerId, protectioncontainers.InquireOperationOptions{Filter: pointer.To(filter)}) if err != nil { return fmt.Errorf("inquire all unprotected files shares under a storage account %q (Resource Group %q): %+v", parsedStorageAccountID.Name, resourceGroup, err) } diff --git a/internal/services/recoveryservices/backup_protected_vm_resource_test.go b/internal/services/recoveryservices/backup_protected_vm_resource_test.go index fd3862519d07..8faf101b1aa8 100644 --- a/internal/services/recoveryservices/backup_protected_vm_resource_test.go +++ b/internal/services/recoveryservices/backup_protected_vm_resource_test.go @@ -3,9 +3,9 @@ package recoveryservices_test import ( "context" "fmt" - "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2021-12-01/protecteditems" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients"